lavf: replace AVStream.codec with AVStream.codecpar

Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.

In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.

There are multiple important problems with this approach:
    - the fields in AVCodecContext are in general one of
        * stream parameters
        * codec options
        * codec state
      However, it's not clear which ones are which. It is consequently
      unclear which fields are a demuxer allowed to set or a muxer allowed to
      read. This leads to erratic behaviour depending on whether decoding or
      encoding is being performed or not (and whether it uses the AVStream
      embedded codec context).
    - various synchronization issues arising from the fact that the same
      context is used by several different APIs (muxers/demuxers,
      parsers, bitstream filters and encoders/decoders) simultaneously, with
      there being no clear rules for who can modify what and the different
      processes being typically delayed with respect to each other.
    - avformat_find_stream_info() making it necessary to support opening
      and closing a single codec context multiple times, thus
      complicating the semantics of freeing various allocated objects in the
      codec context.

Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
pull/200/head
Anton Khirnov 11 years ago
parent a8068346e4
commit 9200514ad8
  1. 2
      libavdevice/alsa.c
  2. 14
      libavdevice/alsa_dec.c
  3. 10
      libavdevice/alsa_enc.c
  4. 13
      libavdevice/bktr.c
  5. 16
      libavdevice/fbdev.c
  6. 10
      libavdevice/jack.c
  7. 12
      libavdevice/libcdio.c
  8. 15
      libavdevice/libdc1394.c
  9. 8
      libavdevice/oss_dec.c
  10. 4
      libavdevice/oss_enc.c
  11. 8
      libavdevice/pulse.c
  12. 8
      libavdevice/sndio_dec.c
  13. 4
      libavdevice/sndio_enc.c
  14. 18
      libavdevice/v4l2.c
  15. 35
      libavdevice/vfwcap.c
  16. 15
      libavdevice/x11grab.c
  17. 11
      libavdevice/xcbgrab.c
  18. 44
      libavformat/4xm.c
  19. 10
      libavformat/a64.c
  20. 4
      libavformat/aacdec.c
  21. 8
      libavformat/adtsenc.c
  22. 34
      libavformat/adxdec.c
  23. 20
      libavformat/aea.c
  24. 68
      libavformat/aiffdec.c
  25. 34
      libavformat/aiffenc.c
  26. 36
      libavformat/amr.c
  27. 18
      libavformat/anm.c
  28. 32
      libavformat/apc.c
  29. 22
      libavformat/ape.c
  30. 16
      libavformat/apetag.c
  31. 30
      libavformat/asfdec.c
  32. 58
      libavformat/asfenc.c
  33. 10
      libavformat/assdec.c
  34. 16
      libavformat/assenc.c
  35. 30
      libavformat/au.c
  36. 12
      libavformat/audiointerleave.c
  37. 24
      libavformat/avformat.h
  38. 135
      libavformat/avidec.c
  39. 98
      libavformat/avienc.c
  40. 58
      libavformat/avisynth.c
  41. 12
      libavformat/avs.c
  42. 24
      libavformat/bethsoftvid.c
  43. 36
      libavformat/bfi.c
  44. 46
      libavformat/bink.c
  45. 20
      libavformat/bmv.c
  46. 10
      libavformat/c93.c
  47. 64
      libavformat/cafdec.c
  48. 4
      libavformat/cdg.c
  49. 26
      libavformat/cdxl.c
  50. 60
      libavformat/dashenc.c
  51. 18
      libavformat/dauddec.c
  52. 4
      libavformat/daudenc.c
  53. 8
      libavformat/dfa.c
  54. 26
      libavformat/dsicin.c
  55. 16
      libavformat/dss.c
  56. 34
      libavformat/dump.c
  57. 43
      libavformat/dv.c
  58. 25
      libavformat/dvenc.c
  59. 20
      libavformat/dxa.c
  60. 10
      libavformat/eacdata.c
  61. 32
      libavformat/electronicarts.c
  62. 4
      libavformat/ffmetadec.c
  63. 20
      libavformat/filmstripdec.c
  64. 6
      libavformat/filmstripenc.c
  65. 8
      libavformat/flac_picture.c
  66. 14
      libavformat/flacdec.c
  67. 16
      libavformat/flacenc.c
  68. 54
      libavformat/flic.c
  69. 249
      libavformat/flvdec.c
  70. 152
      libavformat/flvenc.c
  71. 16
      libavformat/g722.c
  72. 12
      libavformat/g723_1.c
  73. 33
      libavformat/gif.c
  74. 12
      libavformat/gsmdec.c
  75. 78
      libavformat/gxf.c
  76. 62
      libavformat/gxfenc.c
  77. 14
      libavformat/hdsenc.c
  78. 2
      libavformat/hls.c
  79. 6
      libavformat/hlsenc.c
  80. 18
      libavformat/hnm.c
  81. 4
      libavformat/id3v2.c
  82. 2
      libavformat/id3v2enc.c
  83. 38
      libavformat/idcin.c
  84. 36
      libavformat/idroqdec.c
  85. 54
      libavformat/iff.c
  86. 36
      libavformat/ilbc.c
  87. 28
      libavformat/img2dec.c
  88. 16
      libavformat/img2enc.c
  89. 16
      libavformat/internal.h
  90. 38
      libavformat/ipmovie.c
  91. 32
      libavformat/isom.c
  92. 30
      libavformat/iss.c
  93. 4
      libavformat/iv8.c
  94. 10
      libavformat/ivfdec.c
  95. 12
      libavformat/ivfenc.c
  96. 24
      libavformat/jvdec.c
  97. 16
      libavformat/latmenc.c
  98. 8
      libavformat/lmlm4.c
  99. 32
      libavformat/lxfdec.c
  100. 118
      libavformat/matroskadec.c
  101. Some files were not shown because too many files have changed in this diff Show More

@ -194,7 +194,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;

@ -101,10 +101,10 @@ 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->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = 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;
@ -144,9 +144,9 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
snd_pcm_htimestamp(s->h, &ts_delay, &timestamp);
ts_delay += res;
pkt->pts = timestamp.tv_sec * 1000000LL
+ (timestamp.tv_nsec * st->codec->sample_rate
- (int64_t)ts_delay * 1000000000LL + st->codec->sample_rate * 500LL)
/ (st->codec->sample_rate * 1000LL);
+ (timestamp.tv_nsec * st->codecpar->sample_rate
- (int64_t)ts_delay * 1000000000LL + st->codecpar->sample_rate * 500LL)
/ (st->codecpar->sample_rate * 1000LL);
pkt->size = res * s->frame_size;

@ -54,14 +54,14 @@ static av_cold int audio_write_header(AVFormatContext *s1)
int res;
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;
}

@ -295,13 +295,12 @@ static int grab_read_header(AVFormatContext *s1)
s->height = height;
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 = width;
st->codec->height = 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 = width;
st->codecpar->height = height;
st->avg_frame_rate = framerate;
if (bktr_init(s1->filename, width, height, s->standard,

@ -164,21 +164,21 @@ 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 = (AVRational){fbdev->framerate_q.den, fbdev->framerate_q.num};
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->codecpar->bit_rate =
fbdev->width * fbdev->height * fbdev->bytes_per_pixel * av_q2d(fbdev->framerate_q) * 8;
st->avg_frame_rate = fbdev->framerate_q;
av_log(avctx, AV_LOG_INFO,
"w:%d h:%d bpp:%d pixfmt:%s fps:%d/%d bit_rate:%d\n",
fbdev->width, fbdev->height, fbdev->varinfo.bits_per_pixel,
av_get_pix_fmt_name(pix_fmt),
fbdev->framerate_q.num, fbdev->framerate_q.den,
st->codec->bit_rate);
st->codecpar->bit_rate);
return 0;
fail:

@ -254,14 +254,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;

@ -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];

@ -170,13 +170,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);
@ -187,7 +186,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:

@ -61,10 +61,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;

@ -47,8 +47,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);

@ -107,10 +107,10 @@ static av_cold int pulse_read_header(AVFormatContext *s)
return AVERROR(EIO);
}
/* 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->pts = AV_NOPTS_VALUE;

@ -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 */

@ -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);

@ -827,8 +827,8 @@ static int v4l2_read_header(AVFormatContext *s1)
if ((res = v4l2_set_parameters(s1) < 0))
return res;
st->codec->pix_fmt = fmt_v4l2ff(desired_format, codec_id);
s->frame_size = av_image_get_buffer_size(st->codec->pix_fmt,
st->codecpar->format = 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(s1)) ||
@ -839,14 +839,14 @@ static int v4l2_read_header(AVFormatContext *s1)
s->top_field_first = first_field(s->fd);
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->codec->width = s->width;
st->codec->height = s->height;
st->codec->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8;
st->codecpar->codec_tag =
avcodec_pix_fmt_to_codec_tag(st->codecpar->format);
st->codecpar->width = s->width;
st->codecpar->height = s->height;
st->codecpar->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8;
return 0;
}

@ -244,7 +244,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;
@ -373,29 +373,30 @@ static int vfw_read_header(AVFormatContext *s)
if(!ret)
goto fail_io;
codec = st->codec;
codec->time_base = (AVRational){framerate_q.den, framerate_q.num};
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);
}
}
}

@ -347,16 +347,17 @@ 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;
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(param);

@ -544,13 +544,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);

@ -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;
}
@ -165,23 +165,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;
}

@ -27,7 +27,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
@ -36,20 +36,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:

@ -82,8 +82,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;
ff_id3v1_read(s);

@ -91,11 +91,11 @@ static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t
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 (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;
}

@ -37,10 +37,10 @@ typedef struct ADXDemuxerContext {
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;
size = BLOCK_SIZE * avctx->channels;
size = BLOCK_SIZE * par->channels;
pkt->pos = avio_tell(s->pb);
pkt->stream_index = 0;
@ -64,43 +64,43 @@ 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);
avctx->extradata = av_mallocz(c->header_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata)
par->extradata = av_mallocz(c->header_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!par->extradata)
return AVERROR(ENOMEM);
if (avio_read(s->pb, avctx->extradata, c->header_size) < c->header_size) {
av_freep(&avctx->extradata);
if (avio_read(s->pb, par->extradata, c->header_size) < c->header_size) {
av_freep(&par->extradata);
return AVERROR(EIO);
}
avctx->extradata_size = c->header_size;
par->extradata_size = c->header_size;
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;
}

@ -62,29 +62,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)

@ -90,7 +90,7 @@ static unsigned 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;
@ -99,30 +99,30 @@ static unsigned 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);
val = avio_rb64(pb);
sample_rate = ldexp(val, exp - 16383 - 63);
codec->sample_rate = sample_rate;
par->sample_rate = sample_rate;
size -= 18;
/* get codec id for AIFF-C */
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);
par->codec_tag = avio_rl32(pb);
par->codec_id = ff_codec_get_id(ff_codec_aiff_tags, par->codec_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:
@ -131,37 +131,37 @@ static unsigned 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_G722:
case AV_CODEC_ID_MACE6:
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;
case AV_CODEC_ID_QCELP:
codec->block_align = 35;
par->block_align = 35;
break;
default:
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 = (codec->bits_per_coded_sample * codec->channels) >> 3;
if (!par->block_align)
par->block_align = (par->bits_per_coded_sample * par->channels) >> 3;
if (aiff->block_duration) {
codec->bit_rate = codec->sample_rate * (codec->block_align << 3) /
aiff->block_duration;
par->bit_rate = par->sample_rate * (par->block_align << 3) /
aiff->block_duration;
}
/* Chunk is over */
@ -249,7 +249,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) /* Assume COMM already parsed */
if (st->codecpar->block_align) /* Assume COMM already parsed */
goto got_sound;
if (!pb->seekable) {
av_log(s, AV_LOG_ERROR, "file is not seekable\n");
@ -260,11 +260,11 @@ static int aiff_read_header(AVFormatContext *s)
case MKTAG('w', 'a', 'v', 'e'):
if ((uint64_t)size > (1<<30))
return -1;
st->codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
st->codecpar->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = size;
avio_read(pb, st->codec->extradata, size);
st->codecpar->extradata_size = size;
avio_read(pb, st->codecpar->extradata, size);
break;
default: /* Jump */
if (size & 1) /* Always even aligned */
@ -274,13 +274,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;
@ -306,10 +306,10 @@ static int aiff_read_packet(AVFormatContext *s,
return AVERROR_EOF;
/* Now for that packet */
if (st->codec->block_align >= 33) // GSM, QCLP, IMA4
size = st->codec->block_align;
if (st->codecpar->block_align >= 33) // GSM, QCLP, IMA4
size = st->codecpar->block_align;
else
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)
@ -317,7 +317,7 @@ static int aiff_read_packet(AVFormatContext *s,
/* 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;
}

@ -37,14 +37,14 @@ static int aiff_write_header(AVFormatContext *s)
{
AIFFOutputContext *aiff = s->priv_data;
AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
uint64_t sample_rate;
int aifc = 0;
/* 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 */
@ -54,8 +54,8 @@ static int aiff_write_header(AVFormatContext *s)
ffio_wfourcc(pb, aifc ? "AIFC" : "AIFF");
if (aifc) { // compressed audio
enc->bits_per_coded_sample = 16;
if (!enc->block_align) {
par->bits_per_coded_sample = 16;
if (!par->block_align) {
av_log(s, AV_LOG_ERROR, "block align not set\n");
return -1;
}
@ -68,28 +68,28 @@ 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);
}
@ -100,7 +100,7 @@ static int aiff_write_header(AVFormatContext *s)
avio_wb32(pb, 0); /* Data offset */
avio_wb32(pb, 0); /* Block-size (block align) */
avpriv_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate);
avpriv_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codecpar->sample_rate);
/* Data is starting here */
avio_flush(pb);
@ -119,7 +119,7 @@ static int aiff_write_trailer(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
AIFFOutputContext *aiff = s->priv_data;
AVCodecContext *enc = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
/* Chunks sizes must be even */
int64_t file_size, end_size;
@ -136,7 +136,7 @@ static int aiff_write_trailer(AVFormatContext *s)
/* 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);

@ -37,13 +37,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;
@ -89,25 +89,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);
@ -119,13 +119,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
};
@ -139,12 +139,12 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(EIO);
/* Both AMR formats have 50 frames per second */
s->streams[0]->codec->bit_rate = size*8*50;
s->streams[0]->codecpar->bit_rate = size*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) {

@ -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;

@ -45,33 +45,33 @@ 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);
st->codec->extradata_size = 2 * 4;
st->codec->extradata = av_malloc(st->codec->extradata_size +
AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
st->codecpar->extradata_size = 2 * 4;
st->codecpar->extradata = av_malloc(st->codecpar->extradata_size +
AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
/* initial predictor values for adpcm decoder */
avio_read(pb, st->codec->extradata, 2 * 4);
avio_read(pb, st->codecpar->extradata, 2 * 4);
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;
}

@ -344,23 +344,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 / MAC_SUBFRAME_SIZE;
avpriv_set_pts_info(st, 64, MAC_SUBFRAME_SIZE, ape->samplerate);
st->codec->extradata = av_malloc(APE_EXTRADATA_SIZE);
st->codec->extradata_size = APE_EXTRADATA_SIZE;
AV_WL16(st->codec->extradata + 0, ape->fileversion);
AV_WL16(st->codec->extradata + 2, ape->compressiontype);
AV_WL16(st->codec->extradata + 4, ape->formatflags);
st->codecpar->extradata = av_malloc(APE_EXTRADATA_SIZE);
st->codecpar->extradata_size = APE_EXTRADATA_SIZE;
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++) {

@ -87,22 +87,22 @@ 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 {
st->codec->extradata = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
st->codecpar->extradata = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
if (avio_read(pb, st->codec->extradata, size) != size) {
av_freep(&st->codec->extradata);
if (avio_read(pb, st->codecpar->extradata, size) != size) {
av_freep(&st->codecpar->extradata);
return AVERROR(EIO);
}
st->codec->extradata_size = size;
st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
st->codecpar->extradata_size = size;
st->codecpar->codec_type = AVMEDIA_TYPE_ATTACHMENT;
}
} else {
value = av_malloc(size+1);

@ -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);
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)
if ((ret = ff_get_wav_header(s, pb, st->codecpar, ts_data_len)) < 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;
}

@ -377,7 +377,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
int header_size, n, extra_size, extra_size2, wav_extra_size, file_time;
int has_title;
int metadata_count;
AVCodecContext *enc;
AVCodecParameters *par;
int64_t header_offset, cur_pos, hpos;
int bit_rate;
int64_t duration;
@ -396,11 +396,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
bit_rate = 0;
for (n = 0; n < s->nb_streams; n++) {
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;
bit_rate += par->bit_rate;
}
if (asf->is_streamed) {
@ -479,11 +479,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 = 0;
switch (enc->codec_type) {
switch (par->codec_type) {
case AVMEDIA_TYPE_AUDIO:
wav_extra_size = 0;
extra_size = 18 + wav_extra_size;
@ -491,14 +491,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) {
put_guid(pb, &ff_asf_audio_stream);
put_guid(pb, &ff_asf_audio_conceal_spread);
} else {
@ -512,9 +512,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);
int wavsize = ff_put_wav_header(s, pb, par);
if (wavsize < 0)
return -1;
@ -526,23 +526,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);
ff_put_bmp_header(pb, par, ff_codec_bmp_tags, 1);
}
end_header(pb, hpos);
}
@ -556,17 +556,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;
@ -591,14 +591,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);
@ -813,7 +813,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;
}
@ -855,16 +855,16 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
AVIOContext *pb = s->pb;
ASFStream *stream;
int64_t duration;
AVCodecContext *codec;
AVCodecParameters *par;
int64_t packet_st, pts;
int start_sec, i;
int flags = pkt->flags;
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;

@ -91,11 +91,11 @@ static int read_header(AVFormatContext *s)
if (!st)
return -1;
avpriv_set_pts_info(st, 64, 1, 100);
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codec->codec_id = AV_CODEC_ID_SSA;
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codecpar->codec_id = AV_CODEC_ID_SSA;
header_remaining = INT_MAX;
dst[0] = &st->codec->extradata;
dst[0] = &st->codecpar->extradata;
dst[1] = &ass->event_buffer;
while (!pb->eof_reached) {
uint8_t line[MAX_LINESIZE];
@ -123,7 +123,7 @@ static int read_header(AVFormatContext *s)
else
header_remaining--;
}
st->codec->extradata_size = pos[0];
st->codecpar->extradata_size = pos[0];
if (ass->event_count >= UINT_MAX / sizeof(*ass->event))
goto fail;
@ -163,7 +163,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
if (ret < 0)
return ret;
pkt->flags |= AV_PKT_FLAG_KEY;
pkt->pos = p - ass->event_buffer + s->streams[0]->codec->extradata_size;
pkt->pos = p - ass->event_buffer + s->streams[0]->codecpar->extradata_size;
pkt->pts = pkt->dts = get_pts(p);
memcpy(pkt->data, p, pkt->size);

@ -28,18 +28,18 @@ 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;
uint8_t *last= NULL;
if(s->nb_streams != 1 || avctx->codec_id != AV_CODEC_ID_SSA){
if(s->nb_streams != 1 || par->codec_id != AV_CODEC_ID_SSA){
av_log(s, AV_LOG_ERROR, "Exactly one ASS/SSA stream is needed.\n");
return -1;
}
while(ass->extra_index < avctx->extradata_size){
uint8_t *p = avctx->extradata + ass->extra_index;
while(ass->extra_index < par->extradata_size){
uint8_t *p = par->extradata + ass->extra_index;
uint8_t *end= strchr(p, '\n');
if(!end) end= avctx->extradata + avctx->extradata_size;
if(!end) end= par->extradata + par->extradata_size;
else end++;
avio_write(s->pb, p, end-p);
@ -64,10 +64,10 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
static int write_trailer(AVFormatContext *s)
{
ASSContext *ass = s->priv_data;
AVCodecContext *avctx= s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
avio_write(s->pb, avctx->extradata + ass->extra_index,
avctx->extradata_size - ass->extra_index);
avio_write(s->pb, par->extradata + ass->extra_index,
par->extradata_size - ass->extra_index);
return 0;
}

@ -108,13 +108,13 @@ 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->bit_rate = channels * rate * bps;
st->codec->block_align = channels * bps >> 3;
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->bit_rate = channels * rate * bps;
st->codecpar->block_align = channels * bps >> 3;
st->start_time = 0;
avpriv_set_pts_info(st, 64, 1, rate);
@ -127,12 +127,12 @@ static int au_read_packet(AVFormatContext *s, AVPacket *pkt)
int ret;
ret = av_get_packet(s->pb, pkt, BLOCK_SIZE *
s->streams[0]->codec->block_align);
s->streams[0]->codecpar->block_align);
if (ret < 0)
return ret;
pkt->stream_index = 0;
pkt->duration = ret / s->streams[0]->codec->block_align;
pkt->duration = ret / s->streams[0]->codecpar->block_align;
return 0;
}
@ -157,17 +157,17 @@ AVInputFormat ff_au_demuxer = {
#define AU_UNKNOWN_SIZE ((uint32_t)(~0))
/* AUDIO_FILE header */
static int put_au_header(AVIOContext *pb, AVCodecContext *enc)
static int put_au_header(AVIOContext *pb, AVCodecParameters *par)
{
if (!enc->codec_tag)
if (!par->codec_tag)
return AVERROR(EINVAL);
ffio_wfourcc(pb, ".snd"); /* magic number */
avio_wb32(pb, 24); /* 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);
return 0;
}
@ -179,7 +179,7 @@ static int au_write_header(AVFormatContext *s)
s->priv_data = NULL;
if ((ret = put_au_header(pb, s->streams[0]->codec)) < 0)
if ((ret = put_au_header(pb, s->streams[0]->codecpar)) < 0)
return ret;
avio_flush(pb);

@ -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_free(aic->fifo);
}
}
@ -51,9 +51,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 -1;
@ -106,7 +106,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)
@ -126,7 +126,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 (interleave_new_audio_packet(s, &new_pkt, i, flush))
if ((ret = ff_interleave_add_packet(s, &new_pkt, compare_ts)) < 0)

@ -704,18 +704,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
@ -818,6 +813,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

@ -487,8 +487,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);
av_freep(&s->streams[0]->info);
av_freep(&s->streams[0]);
s->nb_streams = 0;
@ -606,10 +606,10 @@ static int avi_read_header(AVFormatContext *s)
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;
}
@ -617,41 +617,41 @@ 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)) {
st->codec->extradata_size = size - 10 * 4;
st->codec->extradata = av_malloc(st->codec->extradata_size +
AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata) {
st->codec->extradata_size = 0;
st->codecpar->extradata_size = size - 10 * 4;
st->codecpar->extradata = av_malloc(st->codecpar->extradata_size +
AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codecpar->extradata) {
st->codecpar->extradata_size = 0;
return AVERROR(ENOMEM);
}
avio_read(pb,
st->codec->extradata,
st->codec->extradata_size);
st->codecpar->extradata,
st->codecpar->extradata_size);
}
// 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
* Libav. */
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;
#if HAVE_BIGENDIAN
for (i = 0; i < pal_size / 4; i++)
ast->pal[i] = av_bswap32(((uint32_t *)pal_src)[i]);
@ -663,17 +663,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);
@ -682,45 +682,45 @@ 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');
// Support "Resolution 1:1" for Avid AVI Codec
if (tag1 == MKTAG('A', 'V', 'R', 'n') &&
st->codec->extradata_size >= 31 &&
!memcmp(&st->codec->extradata[28], "1:1", 3))
st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
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 +
st->codecpar->extradata_size >= 31 &&
!memcmp(&st->codecpar->extradata[28], "1:1", 3))
st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
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);
ret = ff_get_wav_header(s, pb, st->codecpar, size);
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) */
@ -732,28 +732,28 @@ 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;
/* 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;
}
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;
}
break;
case AVMEDIA_TYPE_SUBTITLE:
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codec->codec_id = AV_CODEC_ID_PROBE;
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codecpar->codec_id = AV_CODEC_ID_PROBE;
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;
}
@ -895,8 +895,7 @@ static int read_gab2_sub(AVStream *st, AVPacket *pkt)
ast->sub_ctx->pb = pb;
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);
}
@ -1022,8 +1021,8 @@ start_sync:
AVIStream *ast1 = st1->priv_data;
// 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)) {
@ -1230,8 +1229,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(st, pkt)) {
} else if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE &&
!st->codecpar->codec_tag && read_gab2_sub(st, pkt)) {
ast->frame_offset++;
avi->stream_index = -1;
ast->remaining = 0;
@ -1255,7 +1254,7 @@ resync:
size);
pkt->stream_index = avi->stream_index;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
AVIndexEntry *e;
int index;
assert(st->index_entries);
@ -1391,7 +1390,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));
}
}
@ -1555,7 +1554,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
if (st2->nb_index_entries <= 0)
continue;
// assert(st2->codec->block_align);
// assert(st2->codecpar->block_align);
assert((int64_t)st2->time_base.num * ast2->rate ==
(int64_t)st2->time_base.den * ast2->scale);
index = av_index_search_timestamp(st2,

@ -111,21 +111,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;
assert(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) {
@ -143,7 +143,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;
@ -169,12 +169,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];
}
}
@ -198,9 +198,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);
@ -213,18 +213,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;
@ -242,9 +242,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);
avio_wl32(pb, 0); /* flags */
@ -268,32 +268,32 @@ static int avi_write_header(AVFormatContext *s)
avio_wl32(pb, 0); /* length, XXX: filled later */
/* suggested buffer size */ //FIXME set at the end to largest chunk
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) {
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:
ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 0);
ff_put_bmp_header(pb, par, ff_codec_bmp_tags, 0);
break;
case AVMEDIA_TYPE_AUDIO:
if (ff_put_wav_header(pb, enc) < 0)
if (ff_put_wav_header(s, pb, par) < 0)
return -1;
break;
default:
@ -320,7 +320,7 @@ static int avi_write_header(AVFormatContext *s)
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, i, enc->codec_type));
ffio_wfourcc(pb, avi_stream2fourcc(tag, i, par->codec_type));
/* dwChunkId */
avio_wl64(pb, 0); /* dwReserved[3] */
// avio_wl32(pb, 0); /* Must be 0. */
@ -329,13 +329,13 @@ static int avi_write_header(AVFormatContext *s)
ff_end_tag(pb, avist->indexes.indx_start);
}
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);
@ -343,18 +343,18 @@ static int avi_write_header(AVFormatContext *s)
avio_wl32(pb, 0); // video standard = unknown
// TODO: should be avg_frame_rate
avio_wl32(pb, lrintf(1.0 / av_q2d(st->time_base)));
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);
@ -412,7 +412,7 @@ static int avi_write_ix(AVFormatContext *s)
AVIStream *avist = s->streams[i]->priv_data;
int64_t ix, pos;
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 */
@ -489,7 +489,7 @@ static int avi_write_idx1(AVFormatContext *s)
if (!empty) {
avist = s->streams[stream_id]->priv_data;
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);
avio_wl32(pb, ie->pos);
@ -513,9 +513,9 @@ static int avi_write_packet(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;
while (enc->block_align == 0 && pkt->dts != AV_NOPTS_VALUE &&
while (par->block_align == 0 && pkt->dts != AV_NOPTS_VALUE &&
pkt->dts > avist->packet_count) {
AVPacket empty_packet;
@ -540,10 +540,10 @@ static int avi_write_packet(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) {
@ -604,15 +604,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;
}
}

@ -233,10 +233,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->time_base = (AVRational) { avs->vi->fps_denominator,
avs->vi->fps_numerator };
@ -249,38 +249,38 @@ 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;
planar = 1;
st->codecpar->format = AV_PIX_FMT_YUV444P;
planar = 1;
break;
case AVS_CS_YV16:
st->codec->pix_fmt = AV_PIX_FMT_YUV422P;
planar = 1;
st->codecpar->format = AV_PIX_FMT_YUV422P;
planar = 1;
break;
case AVS_CS_YV411:
st->codec->pix_fmt = AV_PIX_FMT_YUV411P;
planar = 1;
st->codecpar->format = AV_PIX_FMT_YUV411P;
planar = 1;
break;
case AVS_CS_Y8:
st->codec->pix_fmt = AV_PIX_FMT_GRAY8;
planar = 2;
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;
planar = 1;
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;
planar = 1;
st->codecpar->format = AV_PIX_FMT_YUV420P;
planar = 1;
break;
default:
av_log(s, AV_LOG_ERROR,
@ -309,28 +309,28 @@ 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->time_base = (AVRational) { 1,
avs->vi->audio_samples_per_second };
st->duration = avs->vi->num_audio_samples;
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,
@ -639,7 +639,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);
@ -681,7 +681,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) ||

@ -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;
avs->st_video->avg_frame_rate = (AVRational){avs->fps, 1};
}
@ -200,7 +200,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);

@ -113,13 +113,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)
@ -240,13 +240,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);
}

@ -75,34 +75,34 @@ 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);
vstream->codec->extradata_size = 768;
avio_read(pb, vstream->codec->extradata,
vstream->codec->extradata_size);
vstream->codecpar->extradata = av_malloc(768);
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;
/* 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;
}

@ -86,7 +86,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);
@ -104,8 +104,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);
@ -118,13 +118,13 @@ 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->codec->extradata = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!vst->codec->extradata)
vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codecpar->codec_id = AV_CODEC_ID_BINKVIDEO;
vst->codecpar->extradata = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!vst->codecpar->extradata)
return AVERROR(ENOMEM);
vst->codec->extradata_size = 4;
avio_read(pb, vst->codec->extradata, 4);
vst->codecpar->extradata_size = 4;
avio_read(pb, vst->codecpar->extradata, 4);
bink->num_audio_tracks = avio_rl32(pb);
@ -142,25 +142,25 @@ 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;
}
ast->codec->extradata = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!ast->codec->extradata)
ast->codecpar->extradata = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!ast->codecpar->extradata)
return AVERROR(ENOMEM);
ast->codec->extradata_size = 4;
AV_WL32(ast->codec->extradata, vst->codec->codec_tag);
ast->codecpar->extradata_size = 4;
AV_WL32(ast->codecpar->extradata, vst->codecpar->codec_tag);
}
for (i = 0; i < bink->num_audio_tracks; i++)
@ -242,7 +242,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);

@ -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;

@ -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);

@ -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_rb32(pb);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->sample_rate = av_int2double(avio_rb64(pb));
st->codecpar->codec_tag = avio_rb32(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
/ (uint64_t)caf->frames_per_packet;
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 == MKBETAG('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 == MKBETAG('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
@ -131,8 +131,8 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
}
avio_read(pb, preamble, ALAC_PREAMBLE);
st->codec->extradata = av_mallocz(ALAC_HEADER + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
st->codecpar->extradata = av_mallocz(ALAC_HEADER + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
/* For the old style cookie, we skip 12 bytes, then read 36 bytes.
@ -142,26 +142,26 @@ 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;
}
avio_read(pb, st->codec->extradata, ALAC_HEADER);
avio_read(pb, st->codecpar->extradata, ALAC_HEADER);
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);
avio_read(pb, &st->codec->extradata[24], 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);
avio_read(pb, &st->codecpar->extradata[24], ALAC_NEW_KUKI - 12);
avio_skip(pb, size - ALAC_NEW_KUKI);
}
st->codec->extradata_size = ALAC_HEADER;
st->codecpar->extradata_size = ALAC_HEADER;
} else {
st->codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
st->codecpar->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
avio_read(pb, st->codec->extradata, size);
st->codec->extradata_size = size;
avio_read(pb, st->codecpar->extradata, size);
st->codecpar->extradata_size = size;
}
return 0;
@ -309,7 +309,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->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 "
@ -317,7 +317,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 */

@ -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);

@ -99,17 +99,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);
@ -128,11 +128,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;
st->start_time = 0;
cdxl->video_stream_index = st->index;
if (cdxl->framerate)

@ -105,19 +105,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)
@ -128,17 +128,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')) {
@ -147,8 +147,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) {
@ -506,9 +506,9 @@ static int write_manifest(AVFormatContext *s, int final)
for (i = 0; i < s->nb_streams; i++) {
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\">\n", 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\">\n", i, os->codec_str, os->bandwidth_str, st->codecpar->width, st->codecpar->height);
output_segment_list(&c->streams[i], out, c);
avio_printf(out, "\t\t\t</Representation>\n");
}
@ -519,10 +519,10 @@ static int write_manifest(AVFormatContext *s, int final)
for (i = 0; i < s->nb_streams; i++) {
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");
}
@ -581,7 +581,7 @@ static int dash_write_header(AVFormatContext *s)
AVDictionary *opts = NULL;
char filename[1024];
os->bit_rate = s->streams[i]->codec->bit_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);
@ -611,7 +611,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;
@ -651,12 +651,12 @@ 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)
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;
@ -745,24 +745,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;
}
@ -788,7 +788,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.
@ -867,7 +867,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;
@ -892,7 +892,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) {

@ -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;
}

@ -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;
}

@ -51,10 +51,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");

@ -115,11 +115,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);
@ -128,14 +128,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;
}

@ -141,22 +141,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 = 12000;
st->codecpar->codec_id = AV_CODEC_ID_DSS_SP;
st->codecpar->sample_rate = 12000;
} 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 */

@ -400,8 +400,22 @@ static void dump_stream_format(AVFormatContext *ic, int i,
int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
AVStream *st = ic->streams[i];
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
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;
}
avcodec_string(buf, sizeof(buf), avctx, is_output);
avcodec_free_context(&avctx);
avcodec_string(buf, sizeof(buf), st->codec, is_output);
av_log(NULL, AV_LOG_INFO, " Stream #%d:%d", index, i);
/* the pid is an important information, so we display it */
@ -414,31 +428,27 @@ 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) {
AVRational display_aspect_ratio;
av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
st->codec->width * st->sample_aspect_ratio.num,
st->codec->height * st->sample_aspect_ratio.den,
st->codecpar->width * st->sample_aspect_ratio.num,
st->codecpar->height * st->sample_aspect_ratio.den,
1024 * 1024);
av_log(NULL, AV_LOG_INFO, ", PAR %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 tbn = st->time_base.den && st->time_base.num;
int tbc = st->codec->time_base.den && st->codec->time_base.num;
if (fps || tbn || tbc)
if (fps || tbn)
av_log(NULL, AV_LOG_INFO, "\n ");
if (fps)
print_fps(av_q2d(st->avg_frame_rate), tbn || tbc ? "fps, " : "fps");
print_fps(av_q2d(st->avg_frame_rate), tbn ? "fps, " : "fps");
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)

@ -245,8 +245,8 @@ static int dv_extract_audio_info(DVDemuxContext *c, 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;
@ -254,10 +254,10 @@ static int dv_extract_audio_info(DVDemuxContext *c, 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;
@ -268,21 +268,20 @@ static int dv_extract_audio_info(DVDemuxContext *c, uint8_t *frame)
static int dv_extract_video_info(DVDemuxContext *c, uint8_t *frame)
{
const uint8_t *vsc_pack;
AVCodecContext *avctx;
int apt, is16_9;
int size = 0;
if (c->sys) {
avctx = c->vst->codec;
AVCodecParameters *par = c->vst->codecpar;
avpriv_set_pts_info(c->vst, 64, c->sys->time_base.num,
c->sys->time_base.den);
c->vst->avg_frame_rate = av_inv_q(c->vst->time_base);
if (!avctx->width) {
avctx->width = c->sys->width;
avctx->height = c->sys->height;
if (!par->width) {
par->width = c->sys->width;
par->height = c->sys->height;
}
avctx->pix_fmt = c->sys->pix_fmt;
par->format = c->sys->pix_fmt;
/* finding out SAR is a little bit messy */
vsc_pack = dv_extract_pack(frame, dv_video_control);
@ -290,9 +289,9 @@ static int dv_extract_video_info(DVDemuxContext *c, 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,
(AVRational) { 8, 1 },
c->sys->time_base);
par->bit_rate = av_rescale_q(c->sys->frame_size,
(AVRational) { 8, 1 },
c->sys->time_base);
size = c->sys->frame_size;
}
return size;
@ -315,9 +314,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;
@ -358,7 +357,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
for (i = 0; i < c->ach; i++) {
c->audio_pkt[i].size = size;
c->audio_pkt[i].pts = c->abytes * 30000 * 8 /
c->ast[i]->codec->bit_rate;
c->ast[i]->codecpar->bit_rate;
ppcm[i] = c->audio_buf[i];
}
if (c->ach)
@ -395,8 +394,8 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c,
int64_t timestamp, int flags)
{
// FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk)
const AVDVProfile *sys = av_dv_codec_profile(c->vst->codec->width, c->vst->codec->height,
c->vst->codec->pix_fmt);
const AVDVProfile *sys = av_dv_codec_profile(c->vst->codecpar->width, c->vst->codecpar->height,
c->vst->codecpar->format);
int64_t offset;
int64_t size = avio_size(s->pb) - s->internal->data_offset;
int64_t max_offset = ((size - 1) / sys->frame_size) * sys->frame_size;
@ -416,7 +415,7 @@ void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
c->frames = frame_offset;
if (c->ach)
c->abytes = av_rescale_q(c->frames, c->sys->time_base,
(AVRational) { 8, c->ast[0]->codec->bit_rate });
(AVRational) { 8, c->ast[0]->codecpar->bit_rate });
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
c->audio_pkt[2].size = c->audio_pkt[3].size = 0;

@ -236,7 +236,8 @@ 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;
@ -244,13 +245,13 @@ static int dv_assemble_frame(DVMuxContext *c, AVStream* st,
*frame = &c->frame_buf[0];
reqasize = 4 * dv_audio_frame_size(c->sys, c->frames);
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);
}
@ -263,7 +264,7 @@ 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);
/* Let us see if we've got enough audio for one DV frame. */
@ -310,7 +311,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];
@ -325,15 +326,15 @@ 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] && (c->ast[i]->codec->codec_id != AV_CODEC_ID_PCM_S16LE ||
c->ast[i]->codec->sample_rate != 48000 ||
c->ast[i]->codec->channels != 2))
if (c->ast[i] && (c->ast[i]->codecpar->codec_id != AV_CODEC_ID_PCM_S16LE ||
c->ast[i]->codecpar->sample_rate != 48000 ||
c->ast[i]->codecpar->channels != 2))
goto bail_out;
}
c->sys = av_dv_codec_profile(vst->codec->width, vst->codec->height, vst->codec->pix_fmt);
c->sys = av_dv_codec_profile(vst->codecpar->width, vst->codecpar->height, vst->codecpar->format);
if (!c->sys)
goto bail_out;
@ -389,7 +390,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);

@ -106,11 +106,11 @@ static int dxa_read_header(AVFormatContext *s)
ast = avformat_new_stream(s, NULL);
if (!ast)
return -1;
ret = ff_get_wav_header(s, pb, ast->codec, fsize);
ret = ff_get_wav_header(s, pb, ast->codecpar, fsize);
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 && !pb->eof_reached){
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);

@ -68,11 +68,11 @@ 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->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->sample_rate = sample_rate;
avpriv_set_pts_info(st, 64, 1, sample_rate);
cdata->audio_pts = 0;

@ -462,11 +462,11 @@ static int ea_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
ea->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = ea->video_codec;
st->codec->codec_tag = 0; /* no fourcc */
st->codec->width = ea->width;
st->codec->height = ea->height;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = ea->video_codec;
st->codecpar->codec_tag = 0; /* no fourcc */
st->codecpar->width = ea->width;
st->codecpar->height = ea->height;
avpriv_set_pts_info(st, 33, ea->time_base.num, ea->time_base.den);
st->avg_frame_rate = (AVRational) { ea->time_base.den,
ea->time_base.num };
@ -497,17 +497,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;
}

@ -137,8 +137,8 @@ static int read_header(AVFormatContext *s)
if (!st)
return -1;
st->codec->codec_type = AVMEDIA_TYPE_DATA;
st->codec->codec_id = AV_CODEC_ID_FFMETADATA;
st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
st->codecpar->codec_id = AV_CODEC_ID_FFMETADATA;
m = &st->metadata;
} else if (!memcmp(line, ID_CHAPTER, strlen(ID_CHAPTER))) {

@ -60,12 +60,12 @@ static int read_header(AVFormatContext *s)
}
avio_skip(pb, 2);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codec->pix_fmt = AV_PIX_FMT_RGBA;
st->codec->codec_tag = 0; /* no fourcc */
st->codec->width = avio_rb16(pb);
st->codec->height = avio_rb16(pb);
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codecpar->format = AV_PIX_FMT_RGBA;
st->codecpar->codec_tag = 0; /* no fourcc */
st->codecpar->width = avio_rb16(pb);
st->codecpar->height = avio_rb16(pb);
film->leading = avio_rb16(pb);
avpriv_set_pts_info(st, 64, 1, avio_rb16(pb));
@ -82,9 +82,9 @@ static int read_packet(AVFormatContext *s,
if (s->pb->eof_reached)
return AVERROR(EIO);
pkt->dts = avio_tell(s->pb) / (st->codec->width * (st->codec->height + film->leading) * 4);
pkt->size = av_get_packet(s->pb, pkt, st->codec->width * st->codec->height * 4);
avio_skip(s->pb, st->codec->width * (int64_t) film->leading * 4);
pkt->dts = avio_tell(s->pb) / (st->codecpar->width * (st->codecpar->height + film->leading) * 4);
pkt->size = av_get_packet(s->pb, pkt, st->codecpar->width * st->codecpar->height * 4);
avio_skip(s->pb, st->codecpar->width * (int64_t) film->leading * 4);
if (pkt->size < 0)
return pkt->size;
pkt->flags |= AV_PKT_FLAG_KEY;
@ -94,7 +94,7 @@ static int read_packet(AVFormatContext *s,
static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
{
AVStream *st = s->streams[stream_index];
if (avio_seek(s->pb, FFMAX(timestamp, 0) * st->codec->width * st->codec->height * 4, SEEK_SET) < 0)
if (avio_seek(s->pb, FFMAX(timestamp, 0) * st->codecpar->width * st->codecpar->height * 4, SEEK_SET) < 0)
return -1;
return 0;
}

@ -35,7 +35,7 @@ typedef struct FilmstripMuxContext {
static int write_header(AVFormatContext *s)
{
if (s->streams[0]->codec->pix_fmt != AV_PIX_FMT_RGBA) {
if (s->streams[0]->codecpar->format != AV_PIX_FMT_RGBA) {
av_log(s, AV_LOG_ERROR, "only AV_PIX_FMT_RGBA is supported\n");
return AVERROR_INVALIDDATA;
}
@ -61,8 +61,8 @@ static int write_trailer(AVFormatContext *s)
avio_wb32(pb, film->nb_frames);
avio_wb16(pb, 0); // packing method
avio_wb16(pb, 0); // reserved
avio_wb16(pb, st->codec->width);
avio_wb16(pb, st->codec->height);
avio_wb16(pb, st->codecpar->width);
avio_wb16(pb, st->codecpar->height);
avio_wb16(pb, 0); // leading
// TODO: should be avg_frame_rate
avio_wb16(pb, 1/av_q2d(st->time_base));

@ -131,10 +131,10 @@ int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = id;
st->codec->width = width;
st->codec->height = height;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = id;
st->codecpar->width = width;
st->codecpar->height = height;
av_dict_set(&st->metadata, "comment", ff_id3v2_picture_types[type], 0);
if (desc)
av_dict_set(&st->metadata, "title", desc, AV_DICT_DONT_STRDUP_VAL);

@ -36,8 +36,8 @@ static int flac_read_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_FLAC;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_FLAC;
st->need_parsing = AVSTREAM_PARSE_FULL;
/* the parameters will be extracted from the compressed bitstream */
@ -88,14 +88,14 @@ static int flac_read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
found_streaminfo = 1;
st->codec->extradata = buffer;
st->codec->extradata_size = metadata_size;
st->codecpar->extradata = buffer;
st->codecpar->extradata_size = metadata_size;
buffer = NULL;
/* get sample rate and sample count from STREAMINFO header;
* other parameters will be extracted by the parser */
samplerate = AV_RB24(st->codec->extradata + 10) >> 4;
samples = (AV_RB64(st->codec->extradata + 13) >> 24) & ((1ULL << 36) - 1);
samplerate = AV_RB24(st->codecpar->extradata + 10) >> 4;
samples = (AV_RB64(st->codecpar->extradata + 13) >> 24) & ((1ULL << 36) - 1);
/* set time base and duration */
if (samplerate > 0) {
@ -159,7 +159,7 @@ static int flac_read_header(AVFormatContext *s)
av_log(s, AV_LOG_WARNING,
"Invalid value of WAVEFORMATEXTENSIBLE_CHANNEL_MASK\n");
} else {
st->codec->channel_layout = mask;
st->codecpar->channel_layout = mask;
av_dict_set(&s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", NULL, 0);
}
}

@ -77,21 +77,21 @@ static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m,
static int flac_write_header(struct AVFormatContext *s)
{
int ret;
AVCodecContext *codec = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
FlacMuxerContext *c = s->priv_data;
if (!c->write_header)
return 0;
ret = ff_flac_write_header(s->pb, codec->extradata,
codec->extradata_size, 0);
ret = ff_flac_write_header(s->pb, par->extradata,
par->extradata_size, 0);
if (ret)
return ret;
/* add the channel layout tag */
if (codec->channel_layout &&
!(codec->channel_layout & ~0x3ffffULL) &&
!ff_flac_is_native_layout(codec->channel_layout)) {
if (par->channel_layout &&
!(par->channel_layout & ~0x3ffffULL) &&
!ff_flac_is_native_layout(par->channel_layout)) {
AVDictionaryEntry *chmask = av_dict_get(s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK",
NULL, 0);
@ -100,7 +100,7 @@ static int flac_write_header(struct AVFormatContext *s)
"already present, this muxer will not overwrite it.\n");
} else {
uint8_t buf[32];
snprintf(buf, sizeof(buf), "0x%"PRIx64, codec->channel_layout);
snprintf(buf, sizeof(buf), "0x%"PRIx64, par->channel_layout);
av_dict_set(&s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);
}
}
@ -125,7 +125,7 @@ static int flac_write_trailer(struct AVFormatContext *s)
int64_t file_size;
FlacMuxerContext *c = s->priv_data;
uint8_t *streaminfo = c->streaminfo ? c->streaminfo :
s->streams[0]->codec->extradata;
s->streams[0]->codecpar->extradata;
if (!c->write_header || !streaminfo)
return 0;

@ -109,25 +109,25 @@ static int flic_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
flic->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_FLIC;
st->codec->codec_tag = 0; /* no fourcc */
st->codec->width = AV_RL16(&header[0x08]);
st->codec->height = AV_RL16(&header[0x0A]);
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_FLIC;
st->codecpar->codec_tag = 0; /* no fourcc */
st->codecpar->width = AV_RL16(&header[0x08]);
st->codecpar->height = AV_RL16(&header[0x0A]);
if (!st->codec->width || !st->codec->height) {
if (!st->codecpar->width || !st->codecpar->height) {
/* Ugly hack needed for the following sample: */
/* http://samples.libav.org/fli-flc/fli-bugs/specular.flc */
av_log(s, AV_LOG_WARNING,
"File with no specified width/height. Trying 640x480.\n");
st->codec->width = 640;
st->codec->height = 480;
st->codecpar->width = 640;
st->codecpar->height = 480;
}
/* send over the whole 128-byte FLIC header */
st->codec->extradata_size = FLIC_HEADER_SIZE;
st->codec->extradata = av_malloc(FLIC_HEADER_SIZE);
memcpy(st->codec->extradata, header, FLIC_HEADER_SIZE);
st->codecpar->extradata_size = FLIC_HEADER_SIZE;
st->codecpar->extradata = av_malloc(FLIC_HEADER_SIZE);
memcpy(st->codecpar->extradata, header, FLIC_HEADER_SIZE);
/* peek at the preamble to detect TFTD videos - they seem to always start with an audio chunk */
if (avio_read(pb, preamble, FLIC_PREAMBLE_SIZE) != FLIC_PREAMBLE_SIZE) {
@ -152,22 +152,22 @@ static int flic_read_header(AVFormatContext *s)
flic->audio_stream_index = ast->index;
/* all audio frames are the same size, so use the size of the first chunk for block_align */
ast->codec->block_align = AV_RL32(&preamble[0]);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codec->codec_id = AV_CODEC_ID_PCM_U8;
ast->codec->codec_tag = 0;
ast->codec->sample_rate = FLIC_TFTD_SAMPLE_RATE;
ast->codec->channels = 1;
ast->codec->sample_fmt = AV_SAMPLE_FMT_U8;
ast->codec->bit_rate = st->codec->sample_rate * 8;
ast->codec->bits_per_coded_sample = 8;
ast->codec->channel_layout = AV_CH_LAYOUT_MONO;
ast->codec->extradata_size = 0;
ast->codecpar->block_align = AV_RL32(&preamble[0]);
ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
ast->codecpar->codec_tag = 0;
ast->codecpar->sample_rate = FLIC_TFTD_SAMPLE_RATE;
ast->codecpar->channels = 1;
ast->codecpar->format = AV_SAMPLE_FMT_U8;
ast->codecpar->bit_rate = st->codecpar->sample_rate * 8;
ast->codecpar->bits_per_coded_sample = 8;
ast->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
ast->codecpar->extradata_size = 0;
/* Since the header information is incorrect we have to figure out the
* framerate using block_align and the fact that the audio is 22050 Hz.
* We usually have two cases: 2205 -> 10 fps and 1470 -> 15 fps */
avpriv_set_pts_info(st, 64, ast->codec->block_align, FLIC_TFTD_SAMPLE_RATE);
avpriv_set_pts_info(st, 64, ast->codecpar->block_align, FLIC_TFTD_SAMPLE_RATE);
avpriv_set_pts_info(ast, 64, 1, FLIC_TFTD_SAMPLE_RATE);
} else if (AV_RL16(&header[0x10]) == FLIC_CHUNK_MAGIC_1) {
avpriv_set_pts_info(st, 64, FLIC_MC_SPEED, 70);
@ -176,10 +176,10 @@ static int flic_read_header(AVFormatContext *s)
avio_seek(pb, 12, SEEK_SET);
/* send over abbreviated FLIC header chunk */
av_free(st->codec->extradata);
st->codec->extradata_size = 12;
st->codec->extradata = av_malloc(12);
memcpy(st->codec->extradata, header, 12);
av_free(st->codecpar->extradata);
st->codecpar->extradata_size = 12;
st->codecpar->extradata = av_malloc(12);
memcpy(st->codecpar->extradata, header, 12);
} else if (magic_number == FLIC_FILE_MAGIC_1) {
avpriv_set_pts_info(st, 64, speed, 70);

@ -80,21 +80,21 @@ static AVStream *create_stream(AVFormatContext *s, int codec_type)
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return NULL;
st->codec->codec_type = codec_type;
st->codecpar->codec_type = codec_type;
avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
return st;
}
static int flv_same_audio_codec(AVCodecContext *acodec, int flags)
static int flv_same_audio_codec(AVCodecParameters *apar, int flags)
{
int bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
int flv_codecid = flags & FLV_AUDIO_CODECID_MASK;
int codec_id;
if (!acodec->codec_id && !acodec->codec_tag)
if (!apar->codec_id && !apar->codec_tag)
return 1;
if (acodec->bits_per_coded_sample != bits_per_coded_sample)
if (apar->bits_per_coded_sample != bits_per_coded_sample)
return 0;
switch (flv_codecid) {
@ -107,42 +107,42 @@ static int flv_same_audio_codec(AVCodecContext *acodec, int flags)
#else
: AV_CODEC_ID_PCM_S16LE;
#endif
return codec_id == acodec->codec_id;
return codec_id == apar->codec_id;
case FLV_CODECID_PCM_LE:
codec_id = bits_per_coded_sample == 8
? AV_CODEC_ID_PCM_U8
: AV_CODEC_ID_PCM_S16LE;
return codec_id == acodec->codec_id;
return codec_id == apar->codec_id;
case FLV_CODECID_AAC:
return acodec->codec_id == AV_CODEC_ID_AAC;
return apar->codec_id == AV_CODEC_ID_AAC;
case FLV_CODECID_ADPCM:
return acodec->codec_id == AV_CODEC_ID_ADPCM_SWF;
return apar->codec_id == AV_CODEC_ID_ADPCM_SWF;
case FLV_CODECID_SPEEX:
return acodec->codec_id == AV_CODEC_ID_SPEEX;
return apar->codec_id == AV_CODEC_ID_SPEEX;
case FLV_CODECID_MP3:
return acodec->codec_id == AV_CODEC_ID_MP3;
return apar->codec_id == AV_CODEC_ID_MP3;
case FLV_CODECID_NELLYMOSER_8KHZ_MONO:
case FLV_CODECID_NELLYMOSER_16KHZ_MONO:
case FLV_CODECID_NELLYMOSER:
return acodec->codec_id == AV_CODEC_ID_NELLYMOSER;
return apar->codec_id == AV_CODEC_ID_NELLYMOSER;
case FLV_CODECID_PCM_MULAW:
return acodec->sample_rate == 8000 &&
acodec->codec_id == AV_CODEC_ID_PCM_MULAW;
return apar->sample_rate == 8000 &&
apar->codec_id == AV_CODEC_ID_PCM_MULAW;
case FLV_CODECID_PCM_ALAW:
return acodec->sample_rate == 8000 &&
acodec->codec_id == AV_CODEC_ID_PCM_ALAW;
return apar->sample_rate == 8000 &&
apar->codec_id == AV_CODEC_ID_PCM_ALAW;
default:
return acodec->codec_tag == (flv_codecid >> FLV_AUDIO_CODECID_OFFSET);
return apar->codec_tag == (flv_codecid >> FLV_AUDIO_CODECID_OFFSET);
}
}
static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream,
AVCodecContext *acodec, int flv_codecid)
AVCodecParameters *apar, int flv_codecid)
{
switch (flv_codecid) {
// no distinction between S16 and S8 PCM codec flags
case FLV_CODECID_PCM:
acodec->codec_id = acodec->bits_per_coded_sample == 8
apar->codec_id = apar->bits_per_coded_sample == 8
? AV_CODEC_ID_PCM_U8
#if HAVE_BIGENDIAN
: AV_CODEC_ID_PCM_S16BE;
@ -151,113 +151,113 @@ static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream,
#endif
break;
case FLV_CODECID_PCM_LE:
acodec->codec_id = acodec->bits_per_coded_sample == 8
apar->codec_id = apar->bits_per_coded_sample == 8
? AV_CODEC_ID_PCM_U8
: AV_CODEC_ID_PCM_S16LE;
break;
case FLV_CODECID_AAC:
acodec->codec_id = AV_CODEC_ID_AAC;
apar->codec_id = AV_CODEC_ID_AAC;
break;
case FLV_CODECID_ADPCM:
acodec->codec_id = AV_CODEC_ID_ADPCM_SWF;
apar->codec_id = AV_CODEC_ID_ADPCM_SWF;
break;
case FLV_CODECID_SPEEX:
acodec->codec_id = AV_CODEC_ID_SPEEX;
acodec->sample_rate = 16000;
apar->codec_id = AV_CODEC_ID_SPEEX;
apar->sample_rate = 16000;
break;
case FLV_CODECID_MP3:
acodec->codec_id = AV_CODEC_ID_MP3;
apar->codec_id = AV_CODEC_ID_MP3;
astream->need_parsing = AVSTREAM_PARSE_FULL;
break;
case FLV_CODECID_NELLYMOSER_8KHZ_MONO:
// in case metadata does not otherwise declare samplerate
acodec->sample_rate = 8000;
acodec->codec_id = AV_CODEC_ID_NELLYMOSER;
apar->sample_rate = 8000;
apar->codec_id = AV_CODEC_ID_NELLYMOSER;
break;
case FLV_CODECID_NELLYMOSER_16KHZ_MONO:
acodec->sample_rate = 16000;
acodec->codec_id = AV_CODEC_ID_NELLYMOSER;
apar->sample_rate = 16000;
apar->codec_id = AV_CODEC_ID_NELLYMOSER;
break;
case FLV_CODECID_NELLYMOSER:
acodec->codec_id = AV_CODEC_ID_NELLYMOSER;
apar->codec_id = AV_CODEC_ID_NELLYMOSER;
break;
case FLV_CODECID_PCM_MULAW:
acodec->sample_rate = 8000;
acodec->codec_id = AV_CODEC_ID_PCM_MULAW;
apar->sample_rate = 8000;
apar->codec_id = AV_CODEC_ID_PCM_MULAW;
break;
case FLV_CODECID_PCM_ALAW:
acodec->sample_rate = 8000;
acodec->codec_id = AV_CODEC_ID_PCM_ALAW;
apar->sample_rate = 8000;
apar->codec_id = AV_CODEC_ID_PCM_ALAW;
break;
default:
av_log(s, AV_LOG_INFO, "Unsupported audio codec (%x)\n",
flv_codecid >> FLV_AUDIO_CODECID_OFFSET);
acodec->codec_tag = flv_codecid >> FLV_AUDIO_CODECID_OFFSET;
apar->codec_tag = flv_codecid >> FLV_AUDIO_CODECID_OFFSET;
}
}
static int flv_same_video_codec(AVCodecContext *vcodec, int flags)
static int flv_same_video_codec(AVCodecParameters *vpar, int flags)
{
int flv_codecid = flags & FLV_VIDEO_CODECID_MASK;
if (!vcodec->codec_id && !vcodec->codec_tag)
if (!vpar->codec_id && !vpar->codec_tag)
return 1;
switch (flv_codecid) {
case FLV_CODECID_H263:
return vcodec->codec_id == AV_CODEC_ID_FLV1;
return vpar->codec_id == AV_CODEC_ID_FLV1;
case FLV_CODECID_SCREEN:
return vcodec->codec_id == AV_CODEC_ID_FLASHSV;
return vpar->codec_id == AV_CODEC_ID_FLASHSV;
case FLV_CODECID_SCREEN2:
return vcodec->codec_id == AV_CODEC_ID_FLASHSV2;
return vpar->codec_id == AV_CODEC_ID_FLASHSV2;
case FLV_CODECID_VP6:
return vcodec->codec_id == AV_CODEC_ID_VP6F;
return vpar->codec_id == AV_CODEC_ID_VP6F;
case FLV_CODECID_VP6A:
return vcodec->codec_id == AV_CODEC_ID_VP6A;
return vpar->codec_id == AV_CODEC_ID_VP6A;
case FLV_CODECID_H264:
return vcodec->codec_id == AV_CODEC_ID_H264;
return vpar->codec_id == AV_CODEC_ID_H264;
default:
return vcodec->codec_tag == flv_codecid;
return vpar->codec_tag == flv_codecid;
}
}
static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream,
int flv_codecid, int read)
{
AVCodecContext *vcodec = vstream->codec;
AVCodecParameters *par = vstream->codecpar;
switch (flv_codecid) {
case FLV_CODECID_H263:
vcodec->codec_id = AV_CODEC_ID_FLV1;
par->codec_id = AV_CODEC_ID_FLV1;
break;
case FLV_CODECID_SCREEN:
vcodec->codec_id = AV_CODEC_ID_FLASHSV;
par->codec_id = AV_CODEC_ID_FLASHSV;
break;
case FLV_CODECID_SCREEN2:
vcodec->codec_id = AV_CODEC_ID_FLASHSV2;
par->codec_id = AV_CODEC_ID_FLASHSV2;
break;
case FLV_CODECID_VP6:
vcodec->codec_id = AV_CODEC_ID_VP6F;
par->codec_id = AV_CODEC_ID_VP6F;
case FLV_CODECID_VP6A:
if (flv_codecid == FLV_CODECID_VP6A)
vcodec->codec_id = AV_CODEC_ID_VP6A;
par->codec_id = AV_CODEC_ID_VP6A;
if (read) {
if (vcodec->extradata_size != 1) {
vcodec->extradata = av_malloc(1);
if (vcodec->extradata)
vcodec->extradata_size = 1;
if (par->extradata_size != 1) {
par->extradata = av_malloc(1);
if (par->extradata)
par->extradata_size = 1;
}
if (vcodec->extradata)
vcodec->extradata[0] = avio_r8(s->pb);
if (par->extradata)
par->extradata[0] = avio_r8(s->pb);
else
avio_skip(s->pb, 1);
}
return 1; // 1 byte body size adjustment for flv_read_packet()
case FLV_CODECID_H264:
vcodec->codec_id = AV_CODEC_ID_H264;
par->codec_id = AV_CODEC_ID_H264;
return 3; // not 4, reading packet type will consume one byte
default:
av_log(s, AV_LOG_INFO, "Unsupported video codec (%x)\n", flv_codecid);
vcodec->codec_tag = flv_codecid;
par->codec_tag = flv_codecid;
}
return 0;
@ -368,7 +368,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
AVStream *vstream, const char *key,
int64_t max_pos, int depth)
{
AVCodecContext *acodec, *vcodec;
AVCodecParameters *apar, *vpar;
FLVContext *flv = s->priv_data;
AVIOContext *ioc;
AMFDataType amf_type;
@ -442,43 +442,43 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
if (key) {
// stream info doesn't live any deeper than the first object
if (depth == 1) {
acodec = astream ? astream->codec : NULL;
vcodec = vstream ? vstream->codec : NULL;
apar = astream ? astream->codecpar : NULL;
vpar = vstream ? vstream->codecpar : NULL;
if (amf_type == AMF_DATA_TYPE_NUMBER ||
amf_type == AMF_DATA_TYPE_BOOL) {
if (!strcmp(key, "duration"))
s->duration = num_val * AV_TIME_BASE;
else if (!strcmp(key, "videodatarate") && vcodec &&
else if (!strcmp(key, "videodatarate") && vpar &&
0 <= (int)(num_val * 1024.0))
vcodec->bit_rate = num_val * 1024.0;
else if (!strcmp(key, "audiodatarate") && acodec &&
vpar->bit_rate = num_val * 1024.0;
else if (!strcmp(key, "audiodatarate") && apar &&
0 <= (int)(num_val * 1024.0))
acodec->bit_rate = num_val * 1024.0;
apar->bit_rate = num_val * 1024.0;
else if (!strcmp(key, "datastream")) {
AVStream *st = create_stream(s, AVMEDIA_TYPE_DATA);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_id = AV_CODEC_ID_TEXT;
st->codecpar->codec_id = AV_CODEC_ID_TEXT;
} else if (flv->trust_metadata) {
if (!strcmp(key, "videocodecid") && vcodec) {
if (!strcmp(key, "videocodecid") && vpar) {
flv_set_video_codec(s, vstream, num_val, 0);
} else if (!strcmp(key, "audiocodecid") && acodec) {
} else if (!strcmp(key, "audiocodecid") && apar) {
int id = ((int)num_val) << FLV_AUDIO_CODECID_OFFSET;
flv_set_audio_codec(s, astream, acodec, id);
} else if (!strcmp(key, "audiosamplerate") && acodec) {
acodec->sample_rate = num_val;
} else if (!strcmp(key, "audiosamplesize") && acodec) {
acodec->bits_per_coded_sample = num_val;
} else if (!strcmp(key, "stereo") && acodec) {
acodec->channels = num_val + 1;
acodec->channel_layout = acodec->channels == 2 ?
AV_CH_LAYOUT_STEREO :
AV_CH_LAYOUT_MONO;
} else if (!strcmp(key, "width") && vcodec) {
vcodec->width = num_val;
} else if (!strcmp(key, "height") && vcodec) {
vcodec->height = num_val;
flv_set_audio_codec(s, astream, apar, id);
} else if (!strcmp(key, "audiosamplerate") && apar) {
apar->sample_rate = num_val;
} else if (!strcmp(key, "audiosamplesize") && apar) {
apar->bits_per_coded_sample = num_val;
} else if (!strcmp(key, "stereo") && apar) {
apar->channels = num_val + 1;
apar->channel_layout = apar->channels == 2 ?
AV_CH_LAYOUT_STEREO :
AV_CH_LAYOUT_MONO;
} else if (!strcmp(key, "width") && vpar) {
vpar->width = num_val;
} else if (!strcmp(key, "height") && vpar) {
vpar->height = num_val;
}
}
}
@ -544,9 +544,9 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
// the lookup every time it is called.
for (i = 0; i < s->nb_streams; i++) {
stream = s->streams[i];
if (stream->codec->codec_type == AVMEDIA_TYPE_AUDIO)
if (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
astream = stream;
else if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO)
else if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
vstream = stream;
}
@ -585,12 +585,12 @@ static int flv_read_close(AVFormatContext *s)
static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size)
{
av_free(st->codec->extradata);
st->codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
av_free(st->codecpar->extradata);
st->codecpar->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = size;
avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
st->codecpar->extradata_size = size;
avio_read(s->pb, st->codecpar->extradata, st->codecpar->extradata_size);
return 0;
}
@ -704,7 +704,7 @@ static int flv_data_packet(AVFormatContext *s, AVPacket *pkt,
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_DATA)
if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA)
break;
}
@ -712,7 +712,7 @@ static int flv_data_packet(AVFormatContext *s, AVPacket *pkt,
st = create_stream(s, AVMEDIA_TYPE_DATA);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_id = AV_CODEC_ID_TEXT;
st->codecpar->codec_id = AV_CODEC_ID_TEXT;
}
pkt->dts = dts;
@ -803,12 +803,12 @@ skip:
/* now find stream */
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
if (is_audio && st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (flv_same_audio_codec(st->codec, flags))
if (is_audio && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
if (flv_same_audio_codec(st->codecpar, flags))
break;
} else if (!is_audio &&
st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (flv_same_video_codec(st->codec, flags))
st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (flv_same_video_codec(st->codecpar, flags))
break;
}
}
@ -866,38 +866,43 @@ skip:
sample_rate = 44100 << ((flags & FLV_AUDIO_SAMPLERATE_MASK) >>
FLV_AUDIO_SAMPLERATE_OFFSET) >> 3;
bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
if (!st->codec->channels || !st->codec->sample_rate ||
!st->codec->bits_per_coded_sample) {
st->codec->channels = channels;
st->codec->channel_layout = channels == 1
if (!st->codecpar->channels || !st->codecpar->sample_rate ||
!st->codecpar->bits_per_coded_sample) {
st->codecpar->channels = channels;
st->codecpar->channel_layout = channels == 1
? AV_CH_LAYOUT_MONO
: AV_CH_LAYOUT_STEREO;
st->codec->sample_rate = sample_rate;
st->codec->bits_per_coded_sample = bits_per_coded_sample;
st->codecpar->sample_rate = sample_rate;
st->codecpar->bits_per_coded_sample = bits_per_coded_sample;
}
if (!st->codec->codec_id) {
flv_set_audio_codec(s, st, st->codec,
if (!st->codecpar->codec_id) {
flv_set_audio_codec(s, st, st->codecpar,
flags & FLV_AUDIO_CODECID_MASK);
flv->last_sample_rate =
sample_rate = st->codec->sample_rate;
sample_rate = st->codecpar->sample_rate;
flv->last_channels =
channels = st->codec->channels;
channels = st->codecpar->channels;
} else {
AVCodecContext ctx;
ctx.sample_rate = sample_rate;
ctx.bits_per_coded_sample = bits_per_coded_sample;
flv_set_audio_codec(s, st, &ctx, flags & FLV_AUDIO_CODECID_MASK);
sample_rate = ctx.sample_rate;
AVCodecParameters *par = avcodec_parameters_alloc();
if (!par) {
ret = AVERROR(ENOMEM);
goto leave;
}
par->sample_rate = sample_rate;
par->bits_per_coded_sample = bits_per_coded_sample;
flv_set_audio_codec(s, st, par, flags & FLV_AUDIO_CODECID_MASK);
sample_rate = par->sample_rate;
avcodec_parameters_free(&par);
}
} else {
size -= flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK, 1);
}
if (st->codec->codec_id == AV_CODEC_ID_AAC ||
st->codec->codec_id == AV_CODEC_ID_H264) {
if (st->codecpar->codec_id == AV_CODEC_ID_AAC ||
st->codecpar->codec_id == AV_CODEC_ID_H264) {
int type = avio_r8(s->pb);
size--;
if (st->codec->codec_id == AV_CODEC_ID_H264) {
if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
// sign extension
int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000;
pts = dts + cts;
@ -908,7 +913,7 @@ skip:
}
}
if (type == 0) {
if (st->codec->extradata) {
if (st->codecpar->extradata) {
if ((ret = flv_queue_extradata(flv, s->pb, is_audio, size)) < 0)
return ret;
ret = AVERROR(EAGAIN);
@ -916,24 +921,24 @@ skip:
}
if ((ret = flv_get_extradata(s, st, size)) < 0)
return ret;
if (st->codec->codec_id == AV_CODEC_ID_AAC) {
if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
MPEG4AudioConfig cfg;
/* Workaround for buggy Omnia A/XE encoder */
AVDictionaryEntry *t = av_dict_get(s->metadata, "Encoder", NULL, 0);
if (t && !strcmp(t->value, "Omnia A/XE"))
st->codec->extradata_size = 2;
st->codecpar->extradata_size = 2;
avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata,
st->codec->extradata_size * 8, 1);
st->codec->channels = cfg.channels;
st->codec->channel_layout = 0;
avpriv_mpeg4audio_get_config(&cfg, st->codecpar->extradata,
st->codecpar->extradata_size * 8, 1);
st->codecpar->channels = cfg.channels;
st->codecpar->channel_layout = 0;
if (cfg.ext_sample_rate)
st->codec->sample_rate = cfg.ext_sample_rate;
st->codecpar->sample_rate = cfg.ext_sample_rate;
else
st->codec->sample_rate = cfg.sample_rate;
st->codecpar->sample_rate = cfg.sample_rate;
av_log(s, AV_LOG_TRACE, "mp4a config channels %d sample rate %d\n",
st->codec->channels, st->codec->sample_rate);
st->codecpar->channels, st->codecpar->sample_rate);
}
ret = AVERROR(EAGAIN);

@ -61,37 +61,37 @@ typedef struct FLVContext {
int64_t duration;
int64_t delay; ///< first dts delay (needed for AVC & Speex)
AVCodecContext *audio_enc;
AVCodecContext *video_enc;
AVCodecParameters *audio_par;
AVCodecParameters *video_par;
double framerate;
AVCodecContext *data_enc;
AVCodecParameters *data_par;
} FLVContext;
typedef struct FLVStreamContext {
int64_t last_ts; ///< last timestamp for each stream
} FLVStreamContext;
static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
static int get_audio_flags(AVFormatContext *s, AVCodecParameters *par)
{
int flags = (enc->bits_per_coded_sample == 16) ? FLV_SAMPLESSIZE_16BIT
int flags = (par->bits_per_coded_sample == 16) ? FLV_SAMPLESSIZE_16BIT
: FLV_SAMPLESSIZE_8BIT;
if (enc->codec_id == AV_CODEC_ID_AAC) // specs force these parameters
if (par->codec_id == AV_CODEC_ID_AAC) // specs force these parameters
return FLV_CODECID_AAC | FLV_SAMPLERATE_44100HZ |
FLV_SAMPLESSIZE_16BIT | FLV_STEREO;
else if (enc->codec_id == AV_CODEC_ID_SPEEX) {
if (enc->sample_rate != 16000) {
else if (par->codec_id == AV_CODEC_ID_SPEEX) {
if (par->sample_rate != 16000) {
av_log(s, AV_LOG_ERROR,
"flv only supports wideband (16kHz) Speex audio\n");
return -1;
}
if (enc->channels != 1) {
if (par->channels != 1) {
av_log(s, AV_LOG_ERROR, "flv only supports mono Speex audio\n");
return -1;
}
return FLV_CODECID_SPEEX | FLV_SAMPLERATE_11025HZ | FLV_SAMPLESSIZE_16BIT;
} else {
switch (enc->sample_rate) {
switch (par->sample_rate) {
case 44100:
flags |= FLV_SAMPLERATE_44100HZ;
break;
@ -104,7 +104,7 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
case 16000: // nellymoser only
case 8000: // nellymoser only
case 5512: // not MP3
if (enc->codec_id != AV_CODEC_ID_MP3) {
if (par->codec_id != AV_CODEC_ID_MP3) {
flags |= FLV_SAMPLERATE_SPECIAL;
break;
}
@ -116,10 +116,10 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
}
}
if (enc->channels > 1)
if (par->channels > 1)
flags |= FLV_STEREO;
switch (enc->codec_id) {
switch (par->codec_id) {
case AV_CODEC_ID_MP3:
flags |= FLV_CODECID_MP3 | FLV_SAMPLESSIZE_16BIT;
break;
@ -136,9 +136,9 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
flags |= FLV_CODECID_ADPCM | FLV_SAMPLESSIZE_16BIT;
break;
case AV_CODEC_ID_NELLYMOSER:
if (enc->sample_rate == 8000)
if (par->sample_rate == 8000)
flags |= FLV_CODECID_NELLYMOSER_8KHZ_MONO | FLV_SAMPLESSIZE_16BIT;
else if (enc->sample_rate == 16000)
else if (par->sample_rate == 16000)
flags |= FLV_CODECID_NELLYMOSER_16KHZ_MONO | FLV_SAMPLESSIZE_16BIT;
else
flags |= FLV_CODECID_NELLYMOSER | FLV_SAMPLESSIZE_16BIT;
@ -150,7 +150,7 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
flags = FLV_CODECID_PCM_ALAW | FLV_SAMPLERATE_SPECIAL | FLV_SAMPLESSIZE_16BIT;
break;
case 0:
flags |= enc->codec_tag << 4;
flags |= par->codec_tag << 4;
break;
default:
av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n");
@ -216,9 +216,9 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
/* mixed array (hash) with size and string/type/data tuples */
avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
metadata_count_pos = avio_tell(pb);
metadata_count = 4 * !!flv->video_enc +
5 * !!flv->audio_enc +
1 * !!flv->data_enc +
metadata_count = 4 * !!flv->video_par +
5 * !!flv->audio_par +
1 * !!flv->data_par +
2; // +2 for duration and file size
avio_wb32(pb, metadata_count);
@ -229,15 +229,15 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
// fill in the guessed duration, it'll be corrected later if incorrect
put_amf_double(pb, s->duration / AV_TIME_BASE);
if (flv->video_enc) {
if (flv->video_par) {
put_amf_string(pb, "width");
put_amf_double(pb, flv->video_enc->width);
put_amf_double(pb, flv->video_par->width);
put_amf_string(pb, "height");
put_amf_double(pb, flv->video_enc->height);
put_amf_double(pb, flv->video_par->height);
put_amf_string(pb, "videodatarate");
put_amf_double(pb, flv->video_enc->bit_rate / 1024.0);
put_amf_double(pb, flv->video_par->bit_rate / 1024.0);
if (flv->framerate != 0.0) {
put_amf_string(pb, "framerate");
@ -246,27 +246,27 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
}
put_amf_string(pb, "videocodecid");
put_amf_double(pb, flv->video_enc->codec_tag);
put_amf_double(pb, flv->video_par->codec_tag);
}
if (flv->audio_enc) {
if (flv->audio_par) {
put_amf_string(pb, "audiodatarate");
put_amf_double(pb, flv->audio_enc->bit_rate / 1024.0);
put_amf_double(pb, flv->audio_par->bit_rate / 1024.0);
put_amf_string(pb, "audiosamplerate");
put_amf_double(pb, flv->audio_enc->sample_rate);
put_amf_double(pb, flv->audio_par->sample_rate);
put_amf_string(pb, "audiosamplesize");
put_amf_double(pb, flv->audio_enc->codec_id == AV_CODEC_ID_PCM_U8 ? 8 : 16);
put_amf_double(pb, flv->audio_par->codec_id == AV_CODEC_ID_PCM_U8 ? 8 : 16);
put_amf_string(pb, "stereo");
put_amf_bool(pb, flv->audio_enc->channels == 2);
put_amf_bool(pb, flv->audio_par->channels == 2);
put_amf_string(pb, "audiocodecid");
put_amf_double(pb, flv->audio_enc->codec_tag);
put_amf_double(pb, flv->audio_par->codec_tag);
}
if (flv->data_enc) {
if (flv->data_par) {
put_amf_string(pb, "datastream");
put_amf_double(pb, 0.0);
}
@ -316,37 +316,37 @@ static int flv_write_header(AVFormatContext *s)
int64_t data_size;
for (i = 0; i < s->nb_streams; i++) {
AVCodecContext *enc = s->streams[i]->codec;
AVCodecParameters *par = s->streams[i]->codecpar;
FLVStreamContext *sc;
switch (enc->codec_type) {
switch (par->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (s->streams[i]->avg_frame_rate.den &&
s->streams[i]->avg_frame_rate.num) {
flv->framerate = av_q2d(s->streams[i]->avg_frame_rate);
}
if (flv->video_enc) {
if (flv->video_par) {
av_log(s, AV_LOG_ERROR,
"at most one video stream is supported in flv\n");
return AVERROR(EINVAL);
}
flv->video_enc = enc;
if (!ff_codec_get_tag(flv_video_codec_ids, enc->codec_id))
return unsupported_codec(s, "Video", enc->codec_id);
flv->video_par = par;
if (!ff_codec_get_tag(flv_video_codec_ids, par->codec_id))
return unsupported_codec(s, "Video", par->codec_id);
break;
case AVMEDIA_TYPE_AUDIO:
if (flv->audio_enc) {
if (flv->audio_par) {
av_log(s, AV_LOG_ERROR,
"at most one audio stream is supported in flv\n");
return AVERROR(EINVAL);
}
flv->audio_enc = enc;
if (get_audio_flags(s, enc) < 0)
return unsupported_codec(s, "Audio", enc->codec_id);
flv->audio_par = par;
if (get_audio_flags(s, par) < 0)
return unsupported_codec(s, "Audio", par->codec_id);
break;
case AVMEDIA_TYPE_DATA:
if (enc->codec_id != AV_CODEC_ID_TEXT)
return unsupported_codec(s, "Data", enc->codec_id);
flv->data_enc = enc;
if (par->codec_id != AV_CODEC_ID_TEXT)
return unsupported_codec(s, "Data", par->codec_id);
flv->data_par = par;
break;
default:
av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n");
@ -365,13 +365,13 @@ static int flv_write_header(AVFormatContext *s)
avio_write(pb, "FLV", 3);
avio_w8(pb, 1);
avio_w8(pb, FLV_HEADER_FLAG_HASAUDIO * !!flv->audio_enc +
FLV_HEADER_FLAG_HASVIDEO * !!flv->video_enc);
avio_w8(pb, FLV_HEADER_FLAG_HASAUDIO * !!flv->audio_par +
FLV_HEADER_FLAG_HASVIDEO * !!flv->video_par);
avio_wb32(pb, 9);
avio_wb32(pb, 0);
for (i = 0; i < s->nb_streams; i++)
if (s->streams[i]->codec->codec_tag == 5) {
if (s->streams[i]->codecpar->codec_tag == 5) {
avio_w8(pb, 8); // message type
avio_wb24(pb, 0); // include flags
avio_wb24(pb, 0); // time stamp
@ -383,25 +383,25 @@ static int flv_write_header(AVFormatContext *s)
write_metadata(s, 0);
for (i = 0; i < s->nb_streams; i++) {
AVCodecContext *enc = s->streams[i]->codec;
if (enc->codec_id == AV_CODEC_ID_AAC || enc->codec_id == AV_CODEC_ID_H264) {
AVCodecParameters *par = s->streams[i]->codecpar;
if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264) {
int64_t pos;
avio_w8(pb, enc->codec_type == AVMEDIA_TYPE_VIDEO ?
avio_w8(pb, par->codec_type == AVMEDIA_TYPE_VIDEO ?
FLV_TAG_TYPE_VIDEO : FLV_TAG_TYPE_AUDIO);
avio_wb24(pb, 0); // size patched later
avio_wb24(pb, 0); // ts
avio_w8(pb, 0); // ts ext
avio_wb24(pb, 0); // streamid
pos = avio_tell(pb);
if (enc->codec_id == AV_CODEC_ID_AAC) {
avio_w8(pb, get_audio_flags(s, enc));
if (par->codec_id == AV_CODEC_ID_AAC) {
avio_w8(pb, get_audio_flags(s, par));
avio_w8(pb, 0); // AAC sequence header
avio_write(pb, enc->extradata, enc->extradata_size);
avio_write(pb, par->extradata, par->extradata_size);
} else {
avio_w8(pb, enc->codec_tag | FLV_FRAME_KEY); // flags
avio_w8(pb, par->codec_tag | FLV_FRAME_KEY); // flags
avio_w8(pb, 0); // AVC sequence header
avio_wb24(pb, 0); // composition time
ff_isom_write_avcc(pb, enc->extradata, enc->extradata_size);
ff_isom_write_avcc(pb, par->extradata, par->extradata_size);
}
data_size = avio_tell(pb) - pos;
avio_seek(pb, -data_size - 10, SEEK_CUR);
@ -424,10 +424,10 @@ static int flv_write_trailer(AVFormatContext *s)
/* Add EOS tag */
for (i = 0; i < s->nb_streams; i++) {
AVCodecContext *enc = s->streams[i]->codec;
AVCodecParameters *par = s->streams[i]->codecpar;
FLVStreamContext *sc = s->streams[i]->priv_data;
if (enc->codec_type == AVMEDIA_TYPE_VIDEO &&
enc->codec_id == AV_CODEC_ID_H264)
if (par->codec_type == AVMEDIA_TYPE_VIDEO &&
par->codec_id == AV_CODEC_ID_H264)
put_avc_eos_tag(pb, sc->last_ts);
}
@ -450,7 +450,7 @@ static int flv_write_trailer(AVFormatContext *s)
static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[pkt->stream_index]->codec;
AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
FLVContext *flv = s->priv_data;
FLVStreamContext *sc = s->streams[pkt->stream_index]->priv_data;
unsigned ts;
@ -458,10 +458,10 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
uint8_t *data = NULL;
int flags = 0, flags_size;
if (enc->codec_id == AV_CODEC_ID_VP6F || enc->codec_id == AV_CODEC_ID_VP6A ||
enc->codec_id == AV_CODEC_ID_AAC)
if (par->codec_id == AV_CODEC_ID_VP6F || par->codec_id == AV_CODEC_ID_VP6A ||
par->codec_id == AV_CODEC_ID_AAC)
flags_size = 2;
else if (enc->codec_id == AV_CODEC_ID_H264)
else if (par->codec_id == AV_CODEC_ID_H264)
flags_size = 5;
else
flags_size = 1;
@ -482,16 +482,16 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
s->event_flags &= ~AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
}
switch (enc->codec_type) {
switch (par->codec_type) {
case AVMEDIA_TYPE_VIDEO:
avio_w8(pb, FLV_TAG_TYPE_VIDEO);
flags = ff_codec_get_tag(flv_video_codec_ids, enc->codec_id);
flags = ff_codec_get_tag(flv_video_codec_ids, par->codec_id);
flags |= pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY : FLV_FRAME_INTER;
break;
case AVMEDIA_TYPE_AUDIO:
flags = get_audio_flags(s, enc);
flags = get_audio_flags(s, par);
assert(size);
@ -504,14 +504,14 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(EINVAL);
}
if (enc->codec_id == AV_CODEC_ID_H264)
if (par->codec_id == AV_CODEC_ID_H264)
/* check if extradata looks like MP4 */
if (enc->extradata_size > 0 && *(uint8_t*)enc->extradata != 1)
if (par->extradata_size > 0 && *(uint8_t*)par->extradata != 1)
if (ff_avc_parse_nal_units_buf(pkt->data, &data, &size) < 0)
return -1;
/* check Speex packet duration */
if (enc->codec_id == AV_CODEC_ID_SPEEX && ts - sc->last_ts > 160)
if (par->codec_id == AV_CODEC_ID_SPEEX && ts - sc->last_ts > 160)
av_log(s, AV_LOG_WARNING, "Warning: Speex stream has more than "
"8 frames per packet. Adobe Flash "
"Player cannot handle this!\n");
@ -524,7 +524,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
avio_w8(pb, (ts >> 24) & 0x7F); // timestamps are 32 bits _signed_
avio_wb24(pb, flv->reserved);
if (enc->codec_type == AVMEDIA_TYPE_DATA) {
if (par->codec_type == AVMEDIA_TYPE_DATA) {
int data_size;
int64_t metadata_size_pos = avio_tell(pb);
avio_w8(pb, AMF_DATA_TYPE_STRING);
@ -547,15 +547,15 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
avio_wb32(pb, data_size + 11);
} else {
avio_w8(pb,flags);
if (enc->codec_id == AV_CODEC_ID_VP6F || enc->codec_id == AV_CODEC_ID_VP6A) {
if (enc->extradata_size)
avio_w8(pb, enc->extradata[0]);
if (par->codec_id == AV_CODEC_ID_VP6F || par->codec_id == AV_CODEC_ID_VP6A) {
if (par->extradata_size)
avio_w8(pb, par->extradata[0]);
else
avio_w8(pb, ((FFALIGN(enc->width, 16) - enc->width) << 4) |
(FFALIGN(enc->height, 16) - enc->height));
} else if (enc->codec_id == AV_CODEC_ID_AAC)
avio_w8(pb, ((FFALIGN(par->width, 16) - par->width) << 4) |
(FFALIGN(par->height, 16) - par->height));
} else if (par->codec_id == AV_CODEC_ID_AAC)
avio_w8(pb, 1); // AAC raw
else if (enc->codec_id == AV_CODEC_ID_H264) {
else if (par->codec_id == AV_CODEC_ID_H264) {
avio_w8(pb, 1); // AVC NALU
avio_wb24(pb, pkt->pts - pkt->dts);
}

@ -31,17 +31,17 @@ static int g722_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_ADPCM_G722;
st->codec->sample_rate = 16000;
st->codec->channels = 1;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_G722;
st->codecpar->sample_rate = 16000;
st->codecpar->channels = 1;
st->codec->bits_per_coded_sample =
av_get_bits_per_sample(st->codec->codec_id);
st->codecpar->bits_per_coded_sample =
av_get_bits_per_sample(st->codecpar->codec_id);
assert(st->codec->bits_per_coded_sample > 0);
assert(st->codecpar->bits_per_coded_sample > 0);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}

@ -39,13 +39,13 @@ static av_cold int g723_1_init(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_G723_1;
st->codec->channel_layout = AV_CH_LAYOUT_MONO;
st->codec->channels = 1;
st->codec->sample_rate = 8000;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_G723_1;
st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
st->codecpar->channels = 1;
st->codecpar->sample_rate = 8000;
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;
return 0;

@ -264,7 +264,7 @@ static int gif_write_header(AVFormatContext *s)
{
GIFContext *gif = s->priv_data;
AVIOContext *pb = s->pb;
AVCodecContext *enc, *video_enc;
AVCodecParameters *par, *video_par;
int i, width, height /*, rate*/;
/* XXX: do we reject audio streams or just ignore them ?
@ -274,23 +274,23 @@ static int gif_write_header(AVFormatContext *s)
gif->time = 0;
gif->file_time = 0;
video_enc = NULL;
video_par = NULL;
for (i = 0; i < s->nb_streams; i++) {
enc = s->streams[i]->codec;
if (enc->codec_type != AVMEDIA_TYPE_AUDIO)
video_enc = enc;
par = s->streams[i]->codecpar;
if (par->codec_type != AVMEDIA_TYPE_AUDIO)
video_par = par;
}
if (!video_enc) {
if (!video_par) {
av_free(gif);
return -1;
} else {
width = video_enc->width;
height = video_enc->height;
width = video_par->width;
height = video_par->height;
// rate = video_enc->time_base.den;
}
if (video_enc->pix_fmt != AV_PIX_FMT_RGB24) {
if (video_par->format != AV_PIX_FMT_RGB24) {
av_log(s, AV_LOG_ERROR,
"ERROR: gif only handles the rgb24 pixel format. Use -pix_fmt rgb24.\n");
return AVERROR(EIO);
@ -302,9 +302,10 @@ static int gif_write_header(AVFormatContext *s)
return 0;
}
static int gif_write_video(AVFormatContext *s, AVCodecContext *enc,
static int gif_write_video(AVFormatContext *s, AVStream *st,
const uint8_t *buf, int size)
{
AVCodecParameters *par = st->codecpar;
AVIOContext *pb = s->pb;
int jiffies;
@ -319,26 +320,26 @@ static int gif_write_video(AVFormatContext *s, AVCodecContext *enc,
/* XXX: should use delay, in order to be more accurate */
/* instead of using the same rounded value each time */
/* XXX: don't even remember if I really use it for now */
jiffies = (70 * enc->time_base.num / enc->time_base.den) - 1;
jiffies = (70 * st->time_base.num / st->time_base.den) - 1;
avio_wl16(pb, jiffies);
avio_w8(pb, 0x1f); /* transparent color index */
avio_w8(pb, 0x00);
gif_image_write_image(pb, 0, 0, enc->width, enc->height,
buf, enc->width * 3, AV_PIX_FMT_RGB24);
gif_image_write_image(pb, 0, 0, par->width, par->height,
buf, par->width * 3, AV_PIX_FMT_RGB24);
return 0;
}
static int gif_write_packet(AVFormatContext *s, AVPacket *pkt)
{
AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
if (codec->codec_type == AVMEDIA_TYPE_AUDIO)
AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
if (par->codec_type == AVMEDIA_TYPE_AUDIO)
return 0; /* just ignore audio */
else
return gif_write_video(s, codec, pkt->data, pkt->size);
return gif_write_video(s, s->streams[pkt->stream_index], pkt->data, pkt->size);
}
static int gif_write_trailer(AVFormatContext *s)

@ -62,12 +62,12 @@ static int gsm_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->codec->channels = 1;
st->codec->channel_layout = AV_CH_LAYOUT_MONO;
st->codec->sample_rate = c->sample_rate;
st->codec->bit_rate = GSM_BLOCK_SIZE * 8 * c->sample_rate / GSM_BLOCK_SAMPLES;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = s->iformat->raw_codec_id;
st->codecpar->channels = 1;
st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
st->codecpar->sample_rate = c->sample_rate;
st->codecpar->bit_rate = GSM_BLOCK_SIZE * 8 * c->sample_rate / GSM_BLOCK_SAMPLES;
avpriv_set_pts_info(st, 64, GSM_BLOCK_SAMPLES, GSM_SAMPLE_RATE);

@ -92,69 +92,69 @@ static int get_sindex(AVFormatContext *s, int id, int format) {
switch (format) {
case 3:
case 4:
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_MJPEG;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_MJPEG;
break;
case 13:
case 15:
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_DVVIDEO;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_DVVIDEO;
break;
case 14:
case 16:
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_DVVIDEO;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_DVVIDEO;
break;
case 11:
case 12:
case 20:
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_MPEG2VIDEO;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_MPEG2VIDEO;
st->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
break;
case 22:
case 23:
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_MPEG1VIDEO;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_MPEG1VIDEO;
st->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
break;
case 9:
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_PCM_S24LE;
st->codec->channels = 1;
st->codec->channel_layout = AV_CH_LAYOUT_MONO;
st->codec->sample_rate = 48000;
st->codec->bit_rate = 3 * 1 * 48000 * 8;
st->codec->block_align = 3 * 1;
st->codec->bits_per_coded_sample = 24;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE;
st->codecpar->channels = 1;
st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
st->codecpar->sample_rate = 48000;
st->codecpar->bit_rate = 3 * 1 * 48000 * 8;
st->codecpar->block_align = 3 * 1;
st->codecpar->bits_per_coded_sample = 24;
break;
case 10:
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
st->codec->channels = 1;
st->codec->channel_layout = AV_CH_LAYOUT_MONO;
st->codec->sample_rate = 48000;
st->codec->bit_rate = 2 * 1 * 48000 * 8;
st->codec->block_align = 2 * 1;
st->codec->bits_per_coded_sample = 16;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
st->codecpar->channels = 1;
st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
st->codecpar->sample_rate = 48000;
st->codecpar->bit_rate = 2 * 1 * 48000 * 8;
st->codecpar->block_align = 2 * 1;
st->codecpar->bits_per_coded_sample = 16;
break;
case 17:
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_AC3;
st->codec->channels = 2;
st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
st->codec->sample_rate = 48000;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_AC3;
st->codecpar->channels = 2;
st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
st->codecpar->sample_rate = 48000;
break;
// timecode tracks:
case 7:
case 8:
case 24:
st->codec->codec_type = AVMEDIA_TYPE_DATA;
st->codec->codec_id = AV_CODEC_ID_NONE;
st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
st->codecpar->codec_id = AV_CODEC_ID_NONE;
break;
default:
st->codec->codec_type = AVMEDIA_TYPE_UNKNOWN;
st->codec->codec_id = AV_CODEC_ID_NONE;
st->codecpar->codec_type = AVMEDIA_TYPE_UNKNOWN;
st->codecpar->codec_id = AV_CODEC_ID_NONE;
break;
}
return s->nb_streams - 1;
@ -479,11 +479,11 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
avio_rb32(pb); // "timeline" field number
avio_r8(pb); // flags
avio_r8(pb); // reserved
if (st->codec->codec_id == AV_CODEC_ID_PCM_S24LE ||
st->codec->codec_id == AV_CODEC_ID_PCM_S16LE) {
if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S24LE ||
st->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE) {
int first = field_info >> 16;
int last = field_info & 0xffff; // last is exclusive
int bps = av_get_bits_per_sample(st->codec->codec_id)>>3;
int bps = av_get_bits_per_sample(st->codecpar->codec_id)>>3;
if (first <= last && last*bps <= pkt_len) {
avio_skip(pb, first*bps);
skip = pkt_len - last*bps;
@ -498,7 +498,7 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
pkt->dts = field_nr;
//set duration manually for DV or else lavf misdetects the frame rate
if (st->codec->codec_id == AV_CODEC_ID_DVVIDEO)
if (st->codecpar->codec_id == AV_CODEC_ID_DVVIDEO)
pkt->duration = si->fields_per_frame;
return ret;

@ -107,7 +107,7 @@ static int gxf_find_lines_index(AVStream *st)
int i;
for (i = 0; i < 6; ++i) {
if (st->codec->height == gxf_lines_tab[i].height) {
if (st->codecpar->height == gxf_lines_tab[i].height) {
sc->lines_index = gxf_lines_tab[i].index;
return 0;
}
@ -181,18 +181,18 @@ static int gxf_write_mpeg_auxiliary(AVIOContext *pb, AVStream *st)
if (sc->b_per_i_or_p > 9)
sc->b_per_i_or_p = 9; /* ensure value won't take more than one char */
}
if (st->codec->height == 512 || st->codec->height == 608)
if (st->codecpar->height == 512 || st->codecpar->height == 608)
starting_line = 7; // VBI
else if (st->codec->height == 480)
else if (st->codecpar->height == 480)
starting_line = 20;
else
starting_line = 23; // default PAL
size = snprintf(buffer, 1024, "Ver 1\nBr %.6f\nIpg 1\nPpi %d\nBpiop %d\n"
"Pix 0\nCf %d\nCg %d\nSl %d\nnl16 %d\nVi 1\nf1 1\n",
(float)st->codec->bit_rate, sc->p_per_gop, sc->b_per_i_or_p,
st->codec->pix_fmt == AV_PIX_FMT_YUV422P ? 2 : 1, sc->first_gop_closed == 1,
starting_line, (st->codec->height + 15) / 16);
(float)st->codecpar->bit_rate, sc->p_per_gop, sc->b_per_i_or_p,
st->codecpar->format == AV_PIX_FMT_YUV422P ? 2 : 1, sc->first_gop_closed == 1,
starting_line, (st->codecpar->height + 15) / 16);
avio_w8(pb, TRACK_MPG_AUX);
avio_w8(pb, size + 1);
avio_write(pb, (uint8_t *)buffer, size + 1);
@ -472,7 +472,7 @@ static int gxf_write_umf_media_mpeg(AVIOContext *pb, AVStream *st)
{
GXFStreamContext *sc = st->priv_data;
if (st->codec->pix_fmt == AV_PIX_FMT_YUV422P)
if (st->codecpar->format == AV_PIX_FMT_YUV422P)
avio_wl32(pb, 2);
else
avio_wl32(pb, 1); /* default to 420 */
@ -481,9 +481,9 @@ static int gxf_write_umf_media_mpeg(AVIOContext *pb, AVStream *st)
avio_wl32(pb, 1); /* I picture per GOP */
avio_wl32(pb, sc->p_per_gop);
avio_wl32(pb, sc->b_per_i_or_p);
if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO)
if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO)
avio_wl32(pb, 2);
else if (st->codec->codec_id == AV_CODEC_ID_MPEG1VIDEO)
else if (st->codecpar->codec_id == AV_CODEC_ID_MPEG1VIDEO)
avio_wl32(pb, 1);
else
avio_wl32(pb, 0);
@ -565,7 +565,7 @@ static int gxf_write_umf_media_description(AVFormatContext *s)
gxf_write_umf_media_timecode(pb, sc); /* 8 0bytes */
else {
AVStream *st = s->streams[i];
switch (st->codec->codec_id) {
switch (st->codecpar->codec_id) {
case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO:
gxf_write_umf_media_mpeg(pb, st);
@ -646,22 +646,22 @@ static int gxf_write_header(AVFormatContext *s)
return AVERROR(ENOMEM);
st->priv_data = sc;
sc->media_type = ff_codec_get_tag(gxf_media_types, st->codec->codec_id);
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (st->codec->codec_id != AV_CODEC_ID_PCM_S16LE) {
sc->media_type = ff_codec_get_tag(gxf_media_types, st->codecpar->codec_id);
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
if (st->codecpar->codec_id != AV_CODEC_ID_PCM_S16LE) {
av_log(s, AV_LOG_ERROR, "only 16 BIT PCM LE allowed for now\n");
return -1;
}
if (st->codec->sample_rate != 48000) {
if (st->codecpar->sample_rate != 48000) {
av_log(s, AV_LOG_ERROR, "only 48000hz sampling rate is allowed\n");
return -1;
}
if (st->codec->channels != 1) {
if (st->codecpar->channels != 1) {
av_log(s, AV_LOG_ERROR, "only mono tracks are allowed\n");
return -1;
}
sc->track_type = 2;
sc->sample_rate = st->codec->sample_rate;
sc->sample_rate = st->codecpar->sample_rate;
avpriv_set_pts_info(st, 64, 1, sc->sample_rate);
sc->sample_size = 16;
sc->frame_rate_index = -2;
@ -670,18 +670,18 @@ static int gxf_write_header(AVFormatContext *s)
gxf->audio_tracks++;
gxf->flags |= 0x04000000; /* audio is 16 bit pcm */
media_info = 'A';
} else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
} else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (i != 0) {
av_log(s, AV_LOG_ERROR, "video stream must be the first track\n");
return -1;
}
/* FIXME check from time_base ? */
if (st->codec->height == 480 || st->codec->height == 512) { /* NTSC or NTSC+VBI */
if (st->codecpar->height == 480 || st->codecpar->height == 512) { /* NTSC or NTSC+VBI */
sc->frame_rate_index = 5;
sc->sample_rate = 60;
gxf->flags |= 0x00000080;
gxf->time_base = (AVRational){ 1001, 60000 };
} else if (st->codec->height == 576 || st->codec->height == 608) { /* PAL or PAL+VBI */
} else if (st->codecpar->height == 576 || st->codecpar->height == 608) { /* PAL or PAL+VBI */
sc->frame_rate_index = 6;
sc->media_type++;
sc->sample_rate = 50;
@ -695,12 +695,12 @@ static int gxf_write_header(AVFormatContext *s)
avpriv_set_pts_info(st, 64, gxf->time_base.num, gxf->time_base.den);
if (gxf_find_lines_index(st) < 0)
sc->lines_index = -1;
sc->sample_size = st->codec->bit_rate;
sc->sample_size = st->codecpar->bit_rate;
sc->fields = 2; /* interlaced */
vsc = sc;
switch (st->codec->codec_id) {
switch (st->codecpar->codec_id) {
case AV_CODEC_ID_MJPEG:
sc->track_type = 1;
gxf->flags |= 0x00004000;
@ -719,7 +719,7 @@ static int gxf_write_header(AVFormatContext *s)
media_info = 'M';
break;
case AV_CODEC_ID_DVVIDEO:
if (st->codec->pix_fmt == AV_PIX_FMT_YUV422P) {
if (st->codecpar->format == AV_PIX_FMT_YUV422P) {
sc->media_type += 2;
sc->track_type = 6;
gxf->flags |= 0x00002000;
@ -818,7 +818,7 @@ static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
/* If the video is frame-encoded, the frame numbers shall be represented by
* even field numbers.
* see SMPTE360M-2004 6.4.2.1.3 Media field number */
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
field_nb = gxf->nb_fields;
} else {
field_nb = av_rescale_rnd(pkt->dts, gxf->time_base.den,
@ -828,10 +828,10 @@ static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
avio_w8(pb, sc->media_type);
avio_w8(pb, st->index);
avio_wb32(pb, field_nb);
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
avio_wb16(pb, 0);
avio_wb16(pb, size / 2);
} else if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
} else if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
int frame_type = gxf_parse_mpeg_frame(sc, pkt->data, pkt->size);
if (frame_type == AV_PICTURE_TYPE_I) {
avio_w8(pb, 0x0d);
@ -844,7 +844,7 @@ static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
sc->pframes++;
}
avio_wb24(pb, size);
} else if (st->codec->codec_id == AV_CODEC_ID_DVVIDEO) {
} else if (st->codecpar->codec_id == AV_CODEC_ID_DVVIDEO) {
avio_w8(pb, size / 4096);
avio_wb24(pb, 0);
} else
@ -865,15 +865,15 @@ static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)
int packet_start_offset = avio_tell(pb) / 1024;
gxf_write_packet_header(pb, PKT_MEDIA);
if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO && pkt->size % 4) /* MPEG-2 frames must be padded */
if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO && pkt->size % 4) /* MPEG-2 frames must be padded */
padding = 4 - pkt->size % 4;
else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
padding = GXF_AUDIO_PACKET_SIZE - pkt->size;
gxf_write_media_preamble(s, pkt, pkt->size + padding);
avio_write(pb, pkt->data, pkt->size);
gxf_write_padding(pb, padding);
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (!(gxf->flt_entries_nb % 500)) {
int err;
if ((err = av_reallocp_array(&gxf->flt_entries,
@ -909,7 +909,7 @@ static int gxf_compare_field_nb(AVFormatContext *s, AVPacket *next, AVPacket *cu
for (i = 0; i < 2; i++) {
AVStream *st = s->streams[pkt[i]->stream_index];
sc[i] = st->priv_data;
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
field_nb[i] = av_rescale_rnd(pkt[i]->dts, gxf->time_base.den,
(int64_t)48000*gxf->time_base.num, AV_ROUND_UP);
field_nb[i] &= ~1; // compare against even field number because audio must be before video
@ -923,7 +923,7 @@ static int gxf_compare_field_nb(AVFormatContext *s, AVPacket *next, AVPacket *cu
static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
{
if (pkt && s->streams[pkt->stream_index]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
if (pkt && s->streams[pkt->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
pkt->duration = 2; // enforce 2 fields
return ff_audio_rechunk_interleave(s, out, pkt, flush,
ff_interleave_packet_per_dts, gxf_compare_field_nb);

@ -338,18 +338,18 @@ static int hds_write_header(AVFormatContext *s)
AVFormatContext *ctx;
AVStream *st = s->streams[i];
if (!st->codec->bit_rate) {
if (!st->codecpar->bit_rate) {
av_log(s, AV_LOG_ERROR, "No bit rate set for stream %d\n", i);
ret = AVERROR(EINVAL);
goto fail;
}
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (os->has_video) {
c->nb_streams++;
os++;
}
os->has_video = 1;
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
} else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
if (os->has_audio) {
c->nb_streams++;
os++;
@ -360,7 +360,7 @@ static int hds_write_header(AVFormatContext *s)
ret = AVERROR(EINVAL);
goto fail;
}
os->bitrate += s->streams[i]->codec->bit_rate;
os->bitrate += s->streams[i]->codecpar->bit_rate;
if (!os->ctx) {
os->first_stream = i;
@ -389,8 +389,8 @@ static int hds_write_header(AVFormatContext *s)
ret = AVERROR(ENOMEM);
goto fail;
}
avcodec_copy_context(st->codec, s->streams[i]->codec);
st->codec->codec_tag = 0;
avcodec_parameters_copy(st->codecpar, s->streams[i]->codecpar);
st->codecpar->codec_tag = 0;
st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
st->time_base = s->streams[i]->time_base;
}
@ -517,7 +517,7 @@ static int hds_write_packet(AVFormatContext *s, AVPacket *pkt)
if (st->first_dts == AV_NOPTS_VALUE)
st->first_dts = pkt->dts;
if ((!os->has_video || st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&
if ((!os->has_video || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) &&
av_compare_ts(pkt->dts - st->first_dts, st->time_base,
end_dts, AV_TIME_BASE_Q) >= 0 &&
pkt->flags & AV_PKT_FLAG_KEY && os->packets_written) {

@ -617,7 +617,7 @@ static int hls_read_header(AVFormatContext *s)
ff_program_add_stream_index(s, i, stream_offset + j);
st->id = i;
avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den);
avcodec_copy_context(st->codec, v->ctx->streams[j]->codec);
avcodec_parameters_copy(st->codecpar, v->ctx->streams[j]->codecpar);
if (v->bandwidth)
av_dict_set(&st->metadata, "variant_bitrate", bitrate_str,
0);

@ -82,7 +82,7 @@ static int hls_mux_init(AVFormatContext *s)
AVStream *st;
if (!(st = avformat_new_stream(oc, NULL)))
return AVERROR(ENOMEM);
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;
}
@ -220,7 +220,7 @@ static int hls_write_header(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++)
hls->has_video +=
s->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO;
s->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO;
if (hls->has_video > 1)
av_log(s, AV_LOG_WARNING,
@ -284,7 +284,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
}
if (hls->has_video) {
can_split = st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
can_split = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
pkt->flags & AV_PKT_FLAG_KEY;
}
if (pkt->pts == AV_NOPTS_VALUE)

@ -108,15 +108,15 @@ static int hnm_read_header(AVFormatContext *s)
if (!(vst = avformat_new_stream(s, NULL)))
return AVERROR(ENOMEM);
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = AV_CODEC_ID_HNM4_VIDEO;
vst->codec->codec_tag = 0;
vst->codec->width = hnm->width;
vst->codec->height = hnm->height;
vst->codec->extradata = av_mallocz(1);
vst->codec->extradata_size = 1;
memcpy(vst->codec->extradata, &hnm->version, 1);
vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codecpar->codec_id = AV_CODEC_ID_HNM4_VIDEO;
vst->codecpar->codec_tag = 0;
vst->codecpar->width = hnm->width;
vst->codecpar->height = hnm->height;
vst->codecpar->extradata = av_mallocz(1);
vst->codecpar->extradata_size = 1;
memcpy(vst->codecpar->extradata, &hnm->version, 1);
vst->start_time = 0;

@ -761,8 +761,8 @@ int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta **extra_meta)
return AVERROR(ENOMEM);
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = apic->id;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = apic->id;
if (apic->description[0])
av_dict_set(&st->metadata, "title", apic->description, 0);

@ -171,7 +171,7 @@ int ff_id3v2_write_apic(AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt)
/* get the mimetype*/
while (mime->id != AV_CODEC_ID_NONE) {
if (mime->id == st->codec->codec_id) {
if (mime->id == st->codecpar->codec_id) {
mimetype = mime->str;
break;
}

@ -189,16 +189,16 @@ static int idcin_read_header(AVFormatContext *s)
avpriv_set_pts_info(st, 33, 1, IDCIN_FPS);
st->start_time = 0;
idcin->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_IDCIN;
st->codec->codec_tag = 0; /* no fourcc */
st->codec->width = width;
st->codec->height = height;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_IDCIN;
st->codecpar->codec_tag = 0; /* no fourcc */
st->codecpar->width = width;
st->codecpar->height = height;
/* load up the Huffman tables into extradata */
st->codec->extradata_size = HUFFMAN_TABLE_SIZE;
st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
ret = avio_read(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE);
st->codecpar->extradata_size = HUFFMAN_TABLE_SIZE;
st->codecpar->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
ret = avio_read(pb, st->codecpar->extradata, HUFFMAN_TABLE_SIZE);
if (ret < 0) {
return ret;
} else if (ret != HUFFMAN_TABLE_SIZE) {
@ -214,19 +214,19 @@ static int idcin_read_header(AVFormatContext *s)
avpriv_set_pts_info(st, 63, 1, sample_rate);
st->start_time = 0;
idcin->audio_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_tag = 1;
st->codec->channels = channels;
st->codec->channel_layout = channels > 1 ? AV_CH_LAYOUT_STEREO :
AV_CH_LAYOUT_MONO;
st->codec->sample_rate = sample_rate;
st->codec->bits_per_coded_sample = bytes_per_sample * 8;
st->codec->bit_rate = sample_rate * bytes_per_sample * 8 * channels;
st->codec->block_align = idcin->block_align = bytes_per_sample * channels;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_tag = 1;
st->codecpar->channels = channels;
st->codecpar->channel_layout = channels > 1 ? AV_CH_LAYOUT_STEREO :
AV_CH_LAYOUT_MONO;
st->codecpar->sample_rate = sample_rate;
st->codecpar->bits_per_coded_sample = bytes_per_sample * 8;
st->codecpar->bit_rate = sample_rate * bytes_per_sample * 8 * channels;
st->codecpar->block_align = idcin->block_align = bytes_per_sample * channels;
if (bytes_per_sample == 1)
st->codec->codec_id = AV_CODEC_ID_PCM_U8;
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;
if (sample_rate % 14 != 0) {
idcin->audio_chunk_size1 = (sample_rate / 14) *

@ -127,14 +127,14 @@ static int roq_read_packet(AVFormatContext *s,
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 63, 1, roq->frame_rate);
roq->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_ROQ;
st->codec->codec_tag = 0; /* no fourcc */
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_ROQ;
st->codecpar->codec_tag = 0; /* no fourcc */
if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
st->codec->width = roq->width = AV_RL16(preamble);
st->codec->height = roq->height = AV_RL16(preamble + 2);
st->codecpar->width = roq->width = AV_RL16(preamble);
st->codecpar->height = roq->height = AV_RL16(preamble + 2);
break;
}
/* don't care about this chunk anymore */
@ -175,22 +175,22 @@ static int roq_read_packet(AVFormatContext *s,
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 32, 1, RoQ_AUDIO_SAMPLE_RATE);
roq->audio_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_ROQ_DPCM;
st->codec->codec_tag = 0; /* no tag */
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_ROQ_DPCM;
st->codecpar->codec_tag = 0; /* no tag */
if (chunk_type == RoQ_SOUND_STEREO) {
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;
}
roq->audio_channels = st->codec->channels;
st->codec->sample_rate = RoQ_AUDIO_SAMPLE_RATE;
st->codec->bits_per_coded_sample = 16;
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;
roq->audio_channels = st->codecpar->channels;
st->codecpar->sample_rate = RoQ_AUDIO_SAMPLE_RATE;
st->codecpar->bits_per_coded_sample = 16;
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;
}
case RoQ_QUAD_VQ:
if (chunk_type == RoQ_QUAD_VQ) {

@ -122,11 +122,11 @@ static int iff_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
st->codec->channels = 1;
st->codec->channel_layout = AV_CH_LAYOUT_MONO;
st->codecpar->channels = 1;
st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
avio_skip(pb, 8);
// codec_tag used by ByteRun1 decoder to distinguish progressive (PBM) and interlaced (ILBM) content
st->codec->codec_tag = avio_rl32(pb);
st->codecpar->codec_tag = avio_rl32(pb);
while(!pb->eof_reached) {
uint64_t orig_pos;
@ -138,12 +138,12 @@ static int iff_read_header(AVFormatContext *s)
switch(chunk_id) {
case ID_VHDR:
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
if (data_size < 14)
return AVERROR_INVALIDDATA;
avio_skip(pb, 12);
st->codec->sample_rate = avio_rb16(pb);
st->codecpar->sample_rate = avio_rb16(pb);
if (data_size >= 16) {
avio_skip(pb, 1);
compression = avio_r8(pb);
@ -159,11 +159,11 @@ static int iff_read_header(AVFormatContext *s)
if (data_size < 4)
return AVERROR_INVALIDDATA;
if (avio_rb32(pb) < 6) {
st->codec->channels = 1;
st->codec->channel_layout = AV_CH_LAYOUT_MONO;
st->codecpar->channels = 1;
st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
} else {
st->codec->channels = 2;
st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
st->codecpar->channels = 2;
st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
}
break;
@ -173,22 +173,22 @@ static int iff_read_header(AVFormatContext *s)
data_size);
return AVERROR_INVALIDDATA;
}
st->codec->extradata_size = data_size;
st->codec->extradata = av_malloc(data_size);
if (!st->codec->extradata)
st->codecpar->extradata_size = data_size;
st->codecpar->extradata = av_malloc(data_size);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
if (avio_read(pb, st->codec->extradata, data_size) < 0)
if (avio_read(pb, st->codecpar->extradata, data_size) < 0)
return AVERROR(EIO);
break;
case ID_BMHD:
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
if (data_size <= 8)
return AVERROR_INVALIDDATA;
st->codec->width = avio_rb16(pb);
st->codec->height = avio_rb16(pb);
st->codecpar->width = avio_rb16(pb);
st->codecpar->height = avio_rb16(pb);
avio_skip(pb, 4); // x, y offset
st->codec->bits_per_coded_sample = avio_r8(pb);
st->codecpar->bits_per_coded_sample = avio_r8(pb);
if (data_size >= 11) {
avio_skip(pb, 1); // masking
compression = avio_r8(pb);
@ -229,37 +229,37 @@ static int iff_read_header(AVFormatContext *s)
avio_seek(pb, iff->body_pos, SEEK_SET);
switch(st->codec->codec_type) {
switch(st->codecpar->codec_type) {
case AVMEDIA_TYPE_AUDIO:
avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 32, 1, st->codecpar->sample_rate);
switch(compression) {
case COMP_NONE:
st->codec->codec_id = AV_CODEC_ID_PCM_S8_PLANAR;
st->codecpar->codec_id = AV_CODEC_ID_PCM_S8_PLANAR;
break;
case COMP_FIB:
st->codec->codec_id = AV_CODEC_ID_8SVX_FIB;
st->codecpar->codec_id = AV_CODEC_ID_8SVX_FIB;
break;
case COMP_EXP:
st->codec->codec_id = AV_CODEC_ID_8SVX_EXP;
st->codecpar->codec_id = AV_CODEC_ID_8SVX_EXP;
break;
default:
av_log(s, AV_LOG_ERROR, "unknown compression method\n");
return -1;
}
st->codec->bits_per_coded_sample = 8;
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->bits_per_coded_sample = 8;
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;
break;
case AVMEDIA_TYPE_VIDEO:
switch (compression) {
case BITMAP_RAW:
st->codec->codec_id = AV_CODEC_ID_IFF_ILBM;
st->codecpar->codec_id = AV_CODEC_ID_IFF_ILBM;
break;
case BITMAP_BYTERUN1:
st->codec->codec_id = AV_CODEC_ID_IFF_BYTERUN1;
st->codecpar->codec_id = AV_CODEC_ID_IFF_BYTERUN1;
break;
default:
av_log(s, AV_LOG_ERROR, "unknown compression method\n");

@ -28,22 +28,22 @@ static const char mode30_header[] = "#!iLBC30\n";
static int ilbc_write_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
AVCodecContext *enc;
AVCodecParameters *par;
if (s->nb_streams != 1) {
av_log(s, AV_LOG_ERROR, "Unsupported number of streams\n");
return AVERROR(EINVAL);
}
enc = s->streams[0]->codec;
par = s->streams[0]->codecpar;
if (enc->codec_id != AV_CODEC_ID_ILBC) {
if (par->codec_id != AV_CODEC_ID_ILBC) {
av_log(s, AV_LOG_ERROR, "Unsupported codec\n");
return AVERROR(EINVAL);
}
if (enc->block_align == 50) {
if (par->block_align == 50) {
avio_write(pb, mode30_header, sizeof(mode30_header) - 1);
} else if (enc->block_align == 38) {
} else if (par->block_align == 38) {
avio_write(pb, mode20_header, sizeof(mode20_header) - 1);
} else {
av_log(s, AV_LOG_ERROR, "Unsupported mode\n");
@ -79,18 +79,18 @@ static int ilbc_read_header(AVFormatContext *s)
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_id = AV_CODEC_ID_ILBC;
st->codec->sample_rate = 8000;
st->codec->channels = 1;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_ILBC;
st->codecpar->sample_rate = 8000;
st->codecpar->channels = 1;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->start_time = 0;
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
if (!memcmp(header, mode20_header, sizeof(mode20_header) - 1)) {
st->codec->block_align = 38;
st->codec->bit_rate = 15200;
st->codecpar->block_align = 38;
st->codecpar->bit_rate = 15200;
} else if (!memcmp(header, mode30_header, sizeof(mode30_header) - 1)) {
st->codec->block_align = 50;
st->codec->bit_rate = 13333;
st->codecpar->block_align = 50;
st->codecpar->bit_rate = 13333;
} else {
av_log(s, AV_LOG_ERROR, "Unrecognized iLBC file header\n");
return AVERROR_INVALIDDATA;
@ -102,16 +102,16 @@ static int ilbc_read_header(AVFormatContext *s)
static int ilbc_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
AVCodecContext *enc = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
int ret;
if ((ret = av_new_packet(pkt, enc->block_align)) < 0)
if ((ret = av_new_packet(pkt, par->block_align)) < 0)
return ret;
pkt->stream_index = 0;
pkt->pos = avio_tell(s->pb);
pkt->duration = enc->block_align == 38 ? 160 : 240;
if ((ret = avio_read(s->pb, pkt->data, enc->block_align)) != enc->block_align) {
pkt->duration = par->block_align == 38 ? 160 : 240;
if ((ret = avio_read(s->pb, pkt->data, par->block_align)) != par->block_align) {
av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR(EIO);
}

@ -184,8 +184,8 @@ static int img_read_header(AVFormatContext *s1)
avpriv_set_pts_info(st, 60, framerate.den, framerate.num);
if (width && height) {
st->codec->width = width;
st->codec->height = height;
st->codecpar->width = width;
st->codecpar->height = height;
}
if (!s->is_pipe) {
@ -201,18 +201,18 @@ static int img_read_header(AVFormatContext *s1)
}
if (s1->video_codec_id) {
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = s1->video_codec_id;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = s1->video_codec_id;
} else if (s1->audio_codec_id) {
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = s1->audio_codec_id;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = s1->audio_codec_id;
} else {
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = ff_guess_image2_codec(s->path);
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = ff_guess_image2_codec(s->path);
}
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
pix_fmt != AV_PIX_FMT_NONE)
st->codec->pix_fmt = pix_fmt;
st->codecpar->format = pix_fmt;
return 0;
}
@ -224,7 +224,7 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
int i, res;
int size[3] = { 0 }, ret[3] = { 0 };
AVIOContext *f[3] = { NULL };
AVCodecContext *codec = s1->streams[0]->codec;
AVCodecParameters *par = s1->streams[0]->codecpar;
if (!s->is_pipe) {
/* loop over input */
@ -247,13 +247,13 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
}
size[i] = avio_size(f[i]);
if (codec->codec_id != AV_CODEC_ID_RAWVIDEO)
if (par->codec_id != AV_CODEC_ID_RAWVIDEO)
break;
filename[strlen(filename) - 1] = 'U' + i;
}
if (codec->codec_id == AV_CODEC_ID_RAWVIDEO && !codec->width)
infer_size(&codec->width, &codec->height, size[0]);
if (par->codec_id == AV_CODEC_ID_RAWVIDEO && !par->width)
infer_size(&par->width, &par->height, size[0]);
} else {
f[0] = s1->pb;
if (f[0]->eof_reached)

@ -58,7 +58,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
VideoMuxData *img = s->priv_data;
AVIOContext *pb[3];
char filename[1024];
AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
int i;
if (!img->is_pipe) {
@ -77,7 +77,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(EIO);
}
if (codec->codec_id != AV_CODEC_ID_RAWVIDEO)
if (par->codec_id != AV_CODEC_ID_RAWVIDEO)
break;
filename[strlen(filename) - 1] = 'U' + i;
}
@ -85,8 +85,8 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
pb[0] = s->pb;
}
if (codec->codec_id == AV_CODEC_ID_RAWVIDEO) {
int ysize = codec->width * codec->height;
if (par->codec_id == AV_CODEC_ID_RAWVIDEO) {
int ysize = par->width * par->height;
avio_write(pb[0], pkt->data, ysize);
avio_write(pb[1], pkt->data + ysize, (pkt->size - ysize) / 2);
avio_write(pb[2], pkt->data + ysize + (pkt->size - ysize) / 2, (pkt->size - ysize) / 2);
@ -95,8 +95,8 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
} else {
if (ff_guess_image2_codec(s->filename) == AV_CODEC_ID_JPEG2000) {
AVStream *st = s->streams[0];
if (st->codec->extradata_size > 8 &&
AV_RL32(st->codec->extradata + 4) == MKTAG('j', 'p', '2', 'h')) {
if (st->codecpar->extradata_size > 8 &&
AV_RL32(st->codecpar->extradata + 4) == MKTAG('j', 'p', '2', 'h')) {
if (pkt->size < 8 ||
AV_RL32(pkt->data + 4) != MKTAG('j', 'p', '2', 'c'))
goto error;
@ -108,9 +108,9 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
ffio_wfourcc(pb[0], "jp2 ");
avio_wb32(pb[0], 0);
ffio_wfourcc(pb[0], "jp2 ");
avio_write(pb[0], st->codec->extradata, st->codec->extradata_size);
avio_write(pb[0], st->codecpar->extradata, st->codecpar->extradata_size);
} else if (pkt->size < 8 ||
(!st->codec->extradata_size &&
(!st->codecpar->extradata_size &&
AV_RL32(pkt->data + 4) != MKTAG('j', 'P', ' ', ' '))) { // signature
error:
av_log(s, AV_LOG_ERROR, "malformed JPEG 2000 codestream\n");

@ -102,6 +102,22 @@ struct AVStreamInternal {
* from dts.
*/
int reorder;
/**
* The codec context used by avformat_find_stream_info, the parser, etc.
*/
AVCodecContext *avctx;
/**
* 1 if avctx has been initialized with the values from the codec parameters
*/
int avctx_inited;
enum AVCodecID orig_codec_id;
#if FF_API_LAVF_AVCTX
// whether the deprecated stream codec context needs
// to be filled from the codec parameters
int need_codec_update;
#endif
};
void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem);

@ -584,12 +584,12 @@ static int ipmovie_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 63, 1, 1000000);
ipmovie->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_INTERPLAY_VIDEO;
st->codec->codec_tag = 0; /* no fourcc */
st->codec->width = ipmovie->video_width;
st->codec->height = ipmovie->video_height;
st->codec->bits_per_coded_sample = ipmovie->video_bpp;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_INTERPLAY_VIDEO;
st->codecpar->codec_tag = 0; /* no fourcc */
st->codecpar->width = ipmovie->video_width;
st->codecpar->height = ipmovie->video_height;
st->codecpar->bits_per_coded_sample = ipmovie->video_bpp;
if (ipmovie->audio_type) {
st = avformat_new_stream(s, NULL);
@ -597,19 +597,19 @@ static int ipmovie_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 32, 1, ipmovie->audio_sample_rate);
ipmovie->audio_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = ipmovie->audio_type;
st->codec->codec_tag = 0; /* no tag */
st->codec->channels = ipmovie->audio_channels;
st->codec->channel_layout = st->codec->channels == 1 ? AV_CH_LAYOUT_MONO :
AV_CH_LAYOUT_STEREO;
st->codec->sample_rate = ipmovie->audio_sample_rate;
st->codec->bits_per_coded_sample = ipmovie->audio_bits;
st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
st->codec->bits_per_coded_sample;
if (st->codec->codec_id == AV_CODEC_ID_INTERPLAY_DPCM)
st->codec->bit_rate /= 2;
st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = ipmovie->audio_type;
st->codecpar->codec_tag = 0; /* no tag */
st->codecpar->channels = ipmovie->audio_channels;
st->codecpar->channel_layout = st->codecpar->channels == 1 ? AV_CH_LAYOUT_MONO :
AV_CH_LAYOUT_STEREO;
st->codecpar->sample_rate = ipmovie->audio_sample_rate;
st->codecpar->bits_per_coded_sample = ipmovie->audio_bits;
st->codecpar->bit_rate = st->codecpar->channels * st->codecpar->sample_rate *
st->codecpar->bits_per_coded_sample;
if (st->codecpar->codec_id == AV_CODEC_ID_INTERPLAY_DPCM)
st->codecpar->bit_rate /= 2;
st->codecpar->block_align = st->codecpar->channels * st->codecpar->bits_per_coded_sample;
}
return 0;

@ -449,37 +449,37 @@ int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext
avio_rb32(pb); /* max bitrate */
avio_rb32(pb); /* avg bitrate */
st->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id);
st->codecpar->codec_id = ff_codec_get_id(ff_mp4_obj_type, object_type_id);
av_log(fc, AV_LOG_TRACE, "esds object type id 0x%02x\n", object_type_id);
len = ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4DecSpecificDescrTag) {
av_log(fc, AV_LOG_TRACE, "Specific MPEG4 header len=%d\n", len);
if (!len || (uint64_t)len > (1<<30))
return -1;
av_free(st->codec->extradata);
st->codec->extradata = av_mallocz(len + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
av_free(st->codecpar->extradata);
st->codecpar->extradata = av_mallocz(len + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
avio_read(pb, st->codec->extradata, len);
st->codec->extradata_size = len;
if (st->codec->codec_id == AV_CODEC_ID_AAC) {
avio_read(pb, st->codecpar->extradata, len);
st->codecpar->extradata_size = len;
if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
MPEG4AudioConfig cfg;
avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata,
st->codec->extradata_size * 8, 1);
st->codec->channels = cfg.channels;
avpriv_mpeg4audio_get_config(&cfg, st->codecpar->extradata,
st->codecpar->extradata_size * 8, 1);
st->codecpar->channels = cfg.channels;
if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4
st->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];
st->codecpar->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];
else if (cfg.ext_sample_rate)
st->codec->sample_rate = cfg.ext_sample_rate;
st->codecpar->sample_rate = cfg.ext_sample_rate;
else
st->codec->sample_rate = cfg.sample_rate;
st->codecpar->sample_rate = cfg.sample_rate;
av_log(fc, AV_LOG_TRACE, "mp4a config channels %d obj %d ext obj %d "
"sample rate %d ext sample rate %d\n", st->codec->channels,
"sample rate %d ext sample rate %d\n", st->codecpar->channels,
cfg.object_type, cfg.ext_object_type,
cfg.sample_rate, cfg.ext_sample_rate);
if (!(st->codec->codec_id = ff_codec_get_id(mp4_audio_types,
if (!(st->codecpar->codec_id = ff_codec_get_id(mp4_audio_types,
cfg.object_type)))
st->codec->codec_id = AV_CODEC_ID_AAC;
st->codecpar->codec_id = AV_CODEC_ID_AAC;
}
}
return 0;

@ -93,23 +93,23 @@ static av_cold int iss_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_IMA_ISS;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_ISS;
if (stereo) {
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 = 44100;
st->codecpar->sample_rate = 44100;
if(rate_divisor > 0)
st->codec->sample_rate /= rate_divisor;
st->codec->bits_per_coded_sample = 4;
st->codec->bit_rate = st->codec->channels * st->codec->sample_rate
* st->codec->bits_per_coded_sample;
st->codec->block_align = iss->packet_size;
avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate);
st->codecpar->sample_rate /= rate_divisor;
st->codecpar->bits_per_coded_sample = 4;
st->codecpar->bit_rate = st->codecpar->channels * st->codecpar->sample_rate
* st->codecpar->bits_per_coded_sample;
st->codecpar->block_align = iss->packet_size;
avpriv_set_pts_info(st, 32, 1, st->codecpar->sample_rate);
return 0;
}
@ -124,8 +124,8 @@ static int iss_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->stream_index = 0;
pkt->pts = avio_tell(s->pb) - iss->sample_start_pos;
if(s->streams[0]->codec->channels > 0)
pkt->pts /= s->streams[0]->codec->channels*2;
if(s->streams[0]->codecpar->channels > 0)
pkt->pts /= s->streams[0]->codecpar->channels*2;
return 0;
}

@ -45,8 +45,8 @@ static int read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_MPEG4;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_MPEG4;
st->need_parsing = AVSTREAM_PARSE_FULL;
avpriv_set_pts_info(st, 64, 1, 90000);

@ -46,11 +46,11 @@ static int read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_tag = avio_rl32(s->pb);
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, st->codec->codec_tag);
st->codec->width = avio_rl16(s->pb);
st->codec->height = avio_rl16(s->pb);
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_tag = avio_rl32(s->pb);
st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, st->codecpar->codec_tag);
st->codecpar->width = avio_rl16(s->pb);
st->codecpar->height = avio_rl16(s->pb);
time_base.den = avio_rl32(s->pb);
time_base.num = avio_rl32(s->pb);
st->duration = avio_rl64(s->pb);

@ -22,24 +22,24 @@
static int ivf_write_header(AVFormatContext *s)
{
AVCodecContext *ctx;
AVCodecParameters *par;
AVIOContext *pb = s->pb;
if (s->nb_streams != 1) {
av_log(s, AV_LOG_ERROR, "Format supports only exactly one video stream\n");
return AVERROR(EINVAL);
}
ctx = s->streams[0]->codec;
if (ctx->codec_type != AVMEDIA_TYPE_VIDEO || ctx->codec_id != AV_CODEC_ID_VP8) {
par = s->streams[0]->codecpar;
if (par->codec_type != AVMEDIA_TYPE_VIDEO || par->codec_id != AV_CODEC_ID_VP8) {
av_log(s, AV_LOG_ERROR, "Currently only VP8 is supported!\n");
return AVERROR(EINVAL);
}
avio_write(pb, "DKIF", 4);
avio_wl16(pb, 0); // version
avio_wl16(pb, 32); // header length
avio_wl32(pb, ctx->codec_tag ? ctx->codec_tag : AV_RL32("VP80"));
avio_wl16(pb, ctx->width);
avio_wl16(pb, ctx->height);
avio_wl32(pb, par->codec_tag ? par->codec_tag : AV_RL32("VP80"));
avio_wl16(pb, par->width);
avio_wl16(pb, par->height);
avio_wl32(pb, s->streams[0]->time_base.den);
avio_wl32(pb, s->streams[0]->time_base.num);
avio_wl64(pb, s->streams[0]->duration); // TODO: duration or number of frames?!?

@ -85,11 +85,11 @@ static int read_header(AVFormatContext *s)
if (!ast || !vst)
return AVERROR(ENOMEM);
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = AV_CODEC_ID_JV;
vst->codec->codec_tag = 0; /* no fourcc */
vst->codec->width = avio_rl16(pb);
vst->codec->height = avio_rl16(pb);
vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codecpar->codec_id = AV_CODEC_ID_JV;
vst->codecpar->codec_tag = 0; /* no fourcc */
vst->codecpar->width = avio_rl16(pb);
vst->codecpar->height = avio_rl16(pb);
vst->duration =
vst->nb_frames =
ast->nb_index_entries = avio_rl16(pb);
@ -97,13 +97,13 @@ static int read_header(AVFormatContext *s)
avio_skip(pb, 4);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codec->codec_id = AV_CODEC_ID_PCM_U8;
ast->codec->codec_tag = 0; /* no fourcc */
ast->codec->sample_rate = avio_rl16(pb);
ast->codec->channels = 1;
ast->codec->channel_layout = AV_CH_LAYOUT_MONO;
avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
ast->codecpar->codec_tag = 0; /* no fourcc */
ast->codecpar->sample_rate = avio_rl16(pb);
ast->codecpar->channels = 1;
ast->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
avpriv_set_pts_info(ast, 64, 1, ast->codecpar->sample_rate);
avio_skip(pb, 10);

@ -74,10 +74,10 @@ static int latm_decode_extradata(LATMContext *ctx, uint8_t *buf, int size)
static int latm_write_header(AVFormatContext *s)
{
LATMContext *ctx = s->priv_data;
AVCodecContext *avctx = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
if (avctx->extradata_size > 0 &&
latm_decode_extradata(ctx, avctx->extradata, avctx->extradata_size) < 0)
if (par->extradata_size > 0 &&
latm_decode_extradata(ctx, par->extradata, par->extradata_size) < 0)
return AVERROR_INVALIDDATA;
return 0;
@ -86,7 +86,7 @@ static int latm_write_header(AVFormatContext *s)
static int latm_write_frame_header(AVFormatContext *s, PutBitContext *bs)
{
LATMContext *ctx = s->priv_data;
AVCodecContext *avctx = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
GetBitContext gb;
int header_size;
@ -94,7 +94,7 @@ static int latm_write_frame_header(AVFormatContext *s, PutBitContext *bs)
put_bits(bs, 1, !!ctx->counter);
if (!ctx->counter) {
init_get_bits(&gb, avctx->extradata, avctx->extradata_size * 8);
init_get_bits(&gb, par->extradata, par->extradata_size * 8);
/* StreamMuxConfig */
put_bits(bs, 1, 0); /* audioMuxVersion */
@ -105,10 +105,10 @@ static int latm_write_frame_header(AVFormatContext *s, PutBitContext *bs)
/* AudioSpecificConfig */
if (ctx->object_type == AOT_ALS) {
header_size = avctx->extradata_size-(ctx->off + 7) >> 3;
avpriv_copy_bits(bs, &avctx->extradata[ctx->off], header_size);
header_size = par->extradata_size-(ctx->off + 7) >> 3;
avpriv_copy_bits(bs, &par->extradata[ctx->off], header_size);
} else {
avpriv_copy_bits(bs, avctx->extradata, ctx->off + 3);
avpriv_copy_bits(bs, par->extradata, ctx->off + 3);
if (!ctx->channel_conf) {
avpriv_copy_pce_data(bs, &gb);

@ -65,15 +65,15 @@ static int lmlm4_read_header(AVFormatContext *s)
if (!(st = avformat_new_stream(s, NULL)))
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_MPEG4;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_MPEG4;
st->need_parsing = AVSTREAM_PARSE_HEADERS;
avpriv_set_pts_info(st, 64, 1001, 30000);
if (!(st = avformat_new_stream(s, NULL)))
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_MP2;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_MP2;
st->need_parsing = AVSTREAM_PARSE_HEADERS;
/* the parameters will be extracted from the compressed bitstream */

@ -177,25 +177,25 @@ static int get_packet_header(AVFormatContext *s)
//set codec based on specified audio bitdepth
//we only support tightly packed 16-, 20-, 24- and 32-bit PCM at the moment
st->codec->bits_per_coded_sample = (audio_format >> 6) & 0x3F;
st->codecpar->bits_per_coded_sample = (audio_format >> 6) & 0x3F;
if (st->codec->bits_per_coded_sample != (audio_format & 0x3F)) {
if (st->codecpar->bits_per_coded_sample != (audio_format & 0x3F)) {
av_log(s, AV_LOG_WARNING, "only tightly packed PCM currently supported\n");
return AVERROR_PATCHWELCOME;
}
switch (st->codec->bits_per_coded_sample) {
case 16: st->codec->codec_id = AV_CODEC_ID_PCM_S16LE_PLANAR; break;
case 20: st->codec->codec_id = AV_CODEC_ID_PCM_LXF; break;
case 24: st->codec->codec_id = AV_CODEC_ID_PCM_S24LE_PLANAR; break;
case 32: st->codec->codec_id = AV_CODEC_ID_PCM_S32LE_PLANAR; break;
switch (st->codecpar->bits_per_coded_sample) {
case 16: st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE_PLANAR; break;
case 20: st->codecpar->codec_id = AV_CODEC_ID_PCM_LXF; break;
case 24: st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE_PLANAR; break;
case 32: st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE_PLANAR; break;
default:
av_log(s, AV_LOG_WARNING,
"only 16-, 20-, 24- and 32-bit PCM currently supported\n");
return AVERROR_PATCHWELCOME;
}
samples = track_size * 8 / st->codec->bits_per_coded_sample;
samples = track_size * 8 / st->codecpar->bits_per_coded_sample;
//use audio packet size to determine video standard
//for NTSC we have one 8008-sample audio frame per five video frames
@ -256,10 +256,10 @@ static int lxf_read_header(AVFormatContext *s)
expiration_date = AV_RL16(&header_data[58]);
disk_params = AV_RL32(&header_data[116]);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->bit_rate = 1000000 * ((video_params >> 14) & 0xFF);
st->codec->codec_tag = video_params & 0xF;
st->codec->codec_id = ff_codec_get_id(lxf_tags, st->codec->codec_tag);
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->bit_rate = 1000000 * ((video_params >> 14) & 0xFF);
st->codecpar->codec_tag = video_params & 0xF;
st->codecpar->codec_id = ff_codec_get_id(lxf_tags, st->codecpar->codec_tag);
av_log(s, AV_LOG_DEBUG, "record: %x = %i-%02i-%02i\n",
record_date, 1900 + (record_date & 0x7F), (record_date >> 7) & 0xF,
@ -276,11 +276,11 @@ static int lxf_read_header(AVFormatContext *s)
if (!(st = avformat_new_stream(s, NULL)))
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->sample_rate = LXF_SAMPLERATE;
st->codec->channels = lxf->channels;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->sample_rate = LXF_SAMPLERATE;
st->codecpar->channels = lxf->channels;
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
}
avio_skip(s->pb, lxf->extended_size);

@ -1513,7 +1513,7 @@ static int matroska_parse_flac(AVFormatContext *s,
av_log(s, AV_LOG_WARNING,
"Invalid value of WAVEFORMATEXTENSIBLE_CHANNEL_MASK\n");
} else
st->codec->channel_layout = mask;
st->codecpar->channel_layout = mask;
}
av_dict_free(&dict);
}
@ -1653,10 +1653,10 @@ static int matroska_parse_tracks(AVFormatContext *s)
ffio_init_context(&b, track->codec_priv.data,
track->codec_priv.size,
0, NULL, NULL, NULL, NULL);
ret = ff_get_wav_header(s, &b, st->codec, track->codec_priv.size);
ret = ff_get_wav_header(s, &b, st->codecpar, track->codec_priv.size);
if (ret < 0)
return ret;
codec_id = st->codec->codec_id;
codec_id = st->codecpar->codec_id;
extradata_offset = FFMIN(track->codec_priv.size, 18);
} else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
(track->codec_priv.size >= 86) &&
@ -1775,15 +1775,15 @@ static int matroska_parse_tracks(AVFormatContext *s)
if (!track->audio.buf)
return AVERROR(ENOMEM);
if (codec_id == AV_CODEC_ID_RA_288) {
st->codec->block_align = track->audio.coded_framesize;
st->codecpar->block_align = track->audio.coded_framesize;
track->codec_priv.size = 0;
} else {
if (codec_id == AV_CODEC_ID_SIPR && flavor < 4) {
const int sipr_bit_rate[4] = { 6504, 8496, 5000, 16000 };
track->audio.sub_packet_size = ff_sipr_subpk_size[flavor];
st->codec->bit_rate = sipr_bit_rate[flavor];
st->codecpar->bit_rate = sipr_bit_rate[flavor];
}
st->codec->block_align = track->audio.sub_packet_size;
st->codecpar->block_align = track->audio.sub_packet_size;
extradata_offset = 78;
}
} else if (codec_id == AV_CODEC_ID_FLAC && track->codec_priv.size) {
@ -1807,7 +1807,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
(AVRational){ 1, 1000000000 },
st->time_base);
st->codec->codec_id = codec_id;
st->codecpar->codec_id = codec_id;
st->start_time = 0;
if (strcmp(track->language, "und"))
av_dict_set(&st->metadata, "language", track->language, 0);
@ -1818,17 +1818,17 @@ static int matroska_parse_tracks(AVFormatContext *s)
if (track->flag_forced)
st->disposition |= AV_DISPOSITION_FORCED;
if (!st->codec->extradata) {
if (!st->codecpar->extradata) {
if (extradata) {
st->codec->extradata = extradata;
st->codec->extradata_size = extradata_size;
st->codecpar->extradata = extradata;
st->codecpar->extradata_size = extradata_size;
} else if (track->codec_priv.data && track->codec_priv.size > 0) {
st->codec->extradata = av_mallocz(track->codec_priv.size +
AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
st->codecpar->extradata = av_mallocz(track->codec_priv.size +
AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = track->codec_priv.size;
memcpy(st->codec->extradata,
st->codecpar->extradata_size = track->codec_priv.size;
memcpy(st->codecpar->extradata,
track->codec_priv.data + extradata_offset,
track->codec_priv.size);
}
@ -1838,21 +1838,21 @@ static int matroska_parse_tracks(AVFormatContext *s)
int display_width_mul = 1;
int display_height_mul = 1;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_tag = track->video.fourcc;
st->codec->width = track->video.pixel_width;
st->codec->height = track->video.pixel_height;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_tag = track->video.fourcc;
st->codecpar->width = track->video.pixel_width;
st->codecpar->height = track->video.pixel_height;
if (track->video.stereo_mode && track->video.stereo_mode < MATROSKA_VIDEO_STEREOMODE_TYPE_NB)
mkv_stereo_mode_display_mul(track->video.stereo_mode, &display_width_mul, &display_height_mul);
av_reduce(&st->sample_aspect_ratio.num,
&st->sample_aspect_ratio.den,
st->codec->height * track->video.display_width * display_width_mul,
st->codec->width * track->video.display_height * display_height_mul,
st->codecpar->height * track->video.display_width * display_width_mul,
st->codecpar->width * track->video.display_height * display_height_mul,
255);
if (st->codec->codec_id != AV_CODEC_ID_H264 &&
st->codec->codec_id != AV_CODEC_ID_HEVC)
if (st->codecpar->codec_id != AV_CODEC_ID_H264 &&
st->codecpar->codec_id != AV_CODEC_ID_HEVC)
st->need_parsing = AVSTREAM_PARSE_HEADERS;
if (track->default_duration) {
av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
@ -1866,16 +1866,16 @@ static int matroska_parse_tracks(AVFormatContext *s)
return ret;
}
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->sample_rate = track->audio.out_samplerate;
st->codec->channels = track->audio.channels;
if (st->codec->codec_id != AV_CODEC_ID_AAC)
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->sample_rate = track->audio.out_samplerate;
st->codecpar->channels = track->audio.channels;
if (st->codecpar->codec_id != AV_CODEC_ID_AAC)
st->need_parsing = AVSTREAM_PARSE_HEADERS;
if (st->codec->codec_id == AV_CODEC_ID_MP3)
if (st->codecpar->codec_id == AV_CODEC_ID_MP3)
st->need_parsing = AVSTREAM_PARSE_FULL;
} else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) {
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
if (st->codec->codec_id == AV_CODEC_ID_SSA)
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
if (st->codecpar->codec_id == AV_CODEC_ID_SSA)
matroska->contains_ssa = 1;
}
}
@ -1961,21 +1961,21 @@ static int matroska_read_header(AVFormatContext *s)
break;
av_dict_set(&st->metadata, "filename", attachments[j].filename, 0);
av_dict_set(&st->metadata, "mimetype", attachments[j].mime, 0);
st->codec->codec_id = AV_CODEC_ID_NONE;
st->codecpar->codec_id = AV_CODEC_ID_NONE;
for (i = 0; ff_mkv_image_mime_tags[i].id != AV_CODEC_ID_NONE; i++) {
if (!strncmp(ff_mkv_image_mime_tags[i].str, attachments[j].mime,
strlen(ff_mkv_image_mime_tags[i].str))) {
st->codec->codec_id = ff_mkv_image_mime_tags[i].id;
st->codecpar->codec_id = ff_mkv_image_mime_tags[i].id;
break;
}
}
attachments[j].stream = st;
if (st->codec->codec_id != AV_CODEC_ID_NONE) {
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
if (st->codecpar->codec_id != AV_CODEC_ID_NONE) {
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
av_init_packet(&st->attached_pic);
if ((res = av_new_packet(&st->attached_pic, attachments[j].bin.size)) < 0)
@ -1984,19 +1984,19 @@ static int matroska_read_header(AVFormatContext *s)
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
} else {
st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
st->codec->extradata = av_malloc(attachments[j].bin.size);
if (!st->codec->extradata)
st->codecpar->codec_type = AVMEDIA_TYPE_ATTACHMENT;
st->codecpar->extradata = av_malloc(attachments[j].bin.size);
if (!st->codecpar->extradata)
break;
st->codec->extradata_size = attachments[j].bin.size;
memcpy(st->codec->extradata, attachments[j].bin.data,
st->codecpar->extradata_size = attachments[j].bin.size;
memcpy(st->codecpar->extradata, attachments[j].bin.data,
attachments[j].bin.size);
for (i = 0; ff_mkv_mime_tags[i].id != AV_CODEC_ID_NONE; i++) {
if (!strncmp(ff_mkv_mime_tags[i].str, attachments[j].mime,
strlen(ff_mkv_mime_tags[i].str))) {
st->codec->codec_id = ff_mkv_mime_tags[i].id;
st->codecpar->codec_id = ff_mkv_mime_tags[i].id;
break;
}
}
@ -2184,7 +2184,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
uint8_t *data, int size, uint64_t timecode,
uint64_t duration, int64_t pos)
{
int a = st->codec->block_align;
int a = st->codecpar->block_align;
int sps = track->audio.sub_packet_size;
int cfs = track->audio.coded_framesize;
int h = track->audio.sub_packet_h;
@ -2195,7 +2195,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
if (!track->audio.pkt_cnt) {
if (track->audio.sub_packet_cnt == 0)
track->audio.buf_timecode = timecode;
if (st->codec->codec_id == AV_CODEC_ID_RA_288) {
if (st->codecpar->codec_id == AV_CODEC_ID_RA_288) {
if (size < cfs * h / 2) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Corrupt int4 RM-style audio packet size\n");
@ -2204,7 +2204,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
for (x = 0; x < h / 2; x++)
memcpy(track->audio.buf + x * 2 * w + y * cfs,
data + x * cfs, cfs);
} else if (st->codec->codec_id == AV_CODEC_ID_SIPR) {
} else if (st->codecpar->codec_id == AV_CODEC_ID_SIPR) {
if (size < w) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Corrupt sipr RM-style audio packet size\n");
@ -2224,7 +2224,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
}
if (++track->audio.sub_packet_cnt >= h) {
if (st->codec->codec_id == AV_CODEC_ID_SIPR)
if (st->codecpar->codec_id == AV_CODEC_ID_SIPR)
ff_rm_reorder_sipr_data(track->audio.buf, h, w);
track->audio.sub_packet_cnt = 0;
track->audio.pkt_cnt = h * w / a;
@ -2266,10 +2266,10 @@ static int matroska_parse_wavpack(MatroskaTrack *track, uint8_t *src,
uint16_t ver;
int ret, offset = 0;
if (srclen < 12 || track->stream->codec->extradata_size < 2)
if (srclen < 12 || track->stream->codecpar->extradata_size < 2)
return AVERROR_INVALIDDATA;
ver = AV_RL16(track->stream->codec->extradata);
ver = AV_RL16(track->stream->codecpar->extradata);
samples = AV_RL32(src);
src += 4;
@ -2353,7 +2353,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
return res;
}
if (st->codec->codec_id == AV_CODEC_ID_WAVPACK) {
if (st->codecpar->codec_id == AV_CODEC_ID_WAVPACK) {
uint8_t *wv_data;
res = matroska_parse_wavpack(track, pkt_data, &wv_data, &pkt_size);
if (res < 0) {
@ -2366,7 +2366,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
pkt_data = wv_data;
}
if (st->codec->codec_id == AV_CODEC_ID_PRORES)
if (st->codecpar->codec_id == AV_CODEC_ID_PRORES)
offset = 8;
pkt = av_mallocz(sizeof(AVPacket));
@ -2381,7 +2381,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
return AVERROR(ENOMEM);
}
if (st->codec->codec_id == AV_CODEC_ID_PRORES) {
if (st->codecpar->codec_id == AV_CODEC_ID_PRORES) {
uint8_t *buf = pkt->data;
bytestream_put_be32(&buf, pkt_size);
bytestream_put_be32(&buf, MKBETAG('i', 'c', 'p', 'f'));
@ -2400,23 +2400,23 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
else
pkt->pts = timecode;
pkt->pos = pos;
if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE || st->codec->codec_id == AV_CODEC_ID_TEXT)
if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE || st->codecpar->codec_id == AV_CODEC_ID_TEXT)
pkt->duration = duration;
#if FF_API_CONVERGENCE_DURATION
FF_DISABLE_DEPRECATION_WARNINGS
if (st->codec->codec_id == AV_CODEC_ID_TEXT)
if (st->codecpar->codec_id == AV_CODEC_ID_TEXT)
pkt->convergence_duration = duration;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (st->codec->codec_id == AV_CODEC_ID_SSA)
if (st->codecpar->codec_id == AV_CODEC_ID_SSA)
matroska_fix_ass_packet(matroska, pkt, duration);
if (matroska->prev_pkt &&
timecode != AV_NOPTS_VALUE &&
matroska->prev_pkt->pts == timecode &&
matroska->prev_pkt->stream_index == st->index &&
st->codec->codec_id == AV_CODEC_ID_SSA)
st->codecpar->codec_id == AV_CODEC_ID_SSA)
matroska_merge_packets(matroska->prev_pkt, pkt);
else {
dynarray_add(&matroska->packets, &matroska->num_packets, pkt);
@ -2510,11 +2510,11 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
FFMAX(track->end_timecode, timecode + block_duration);
for (n = 0; n < laces; n++) {
if ((st->codec->codec_id == AV_CODEC_ID_RA_288 ||
st->codec->codec_id == AV_CODEC_ID_COOK ||
st->codec->codec_id == AV_CODEC_ID_SIPR ||
st->codec->codec_id == AV_CODEC_ID_ATRAC3) &&
st->codec->block_align && track->audio.sub_packet_size) {
if ((st->codecpar->codec_id == AV_CODEC_ID_RA_288 ||
st->codecpar->codec_id == AV_CODEC_ID_COOK ||
st->codecpar->codec_id == AV_CODEC_ID_SIPR ||
st->codecpar->codec_id == AV_CODEC_ID_ATRAC3) &&
st->codecpar->block_align && track->audio.sub_packet_size) {
res = matroska_parse_rm_audio(matroska, track, st, data,
lace_size[n],
timecode, duration, pos);

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

Loading…
Cancel
Save