diff options
author | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-10 20:58:15 +0100 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-10 20:59:55 +0100 |
commit | 6f69f7a8bf6a0d013985578df2ef42ee6b1c7994 (patch) | |
tree | 0c2ec8349ff1763d5f48454b8b9f26374dbd80b0 /libavdevice | |
parent | 60b75186b2c878b6257b43c8fcc0b1356ada218e (diff) | |
parent | 9200514ad8717c63f82101dc394f4378854325bf (diff) | |
download | ffmpeg-6f69f7a8bf6a0d013985578df2ef42ee6b1c7994.tar.gz |
Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf':
lavf: replace AVStream.codec with AVStream.codecpar
This has been a HUGE effort from:
- Derek Buitenhuis <derek.buitenhuis@gmail.com>
- Hendrik Leppkes <h.leppkes@gmail.com>
- wm4 <nfxjfg@googlemail.com>
- Clément Bœsch <clement@stupeflix.com>
- James Almer <jamrial@gmail.com>
- Michael Niedermayer <michael@niedermayer.cc>
- Rostislav Pehlivanov <atomnuker@gmail.com>
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavdevice')
-rw-r--r-- | libavdevice/alsa.c | 2 | ||||
-rw-r--r-- | libavdevice/alsa_dec.c | 10 | ||||
-rw-r--r-- | libavdevice/alsa_enc.c | 14 | ||||
-rw-r--r-- | libavdevice/bktr.c | 14 | ||||
-rw-r--r-- | libavdevice/dshow.c | 49 | ||||
-rw-r--r-- | libavdevice/fbdev_dec.c | 16 | ||||
-rw-r--r-- | libavdevice/fbdev_enc.c | 12 | ||||
-rw-r--r-- | libavdevice/gdigrab.c | 9 | ||||
-rw-r--r-- | libavdevice/jack.c | 10 | ||||
-rw-r--r-- | libavdevice/lavfi.c | 32 | ||||
-rw-r--r-- | libavdevice/libcdio.c | 12 | ||||
-rw-r--r-- | libavdevice/libdc1394.c | 15 | ||||
-rw-r--r-- | libavdevice/openal-dec.c | 12 | ||||
-rw-r--r-- | libavdevice/opengl_enc.c | 16 | ||||
-rw-r--r-- | libavdevice/oss_dec.c | 8 | ||||
-rw-r--r-- | libavdevice/oss_enc.c | 4 | ||||
-rw-r--r-- | libavdevice/pulse_audio_dec.c | 8 | ||||
-rw-r--r-- | libavdevice/pulse_audio_enc.c | 25 | ||||
-rw-r--r-- | libavdevice/sdl.c | 32 | ||||
-rw-r--r-- | libavdevice/sndio_dec.c | 8 | ||||
-rw-r--r-- | libavdevice/sndio_enc.c | 4 | ||||
-rw-r--r-- | libavdevice/v4l2.c | 22 | ||||
-rw-r--r-- | libavdevice/v4l2enc.c | 18 | ||||
-rw-r--r-- | libavdevice/vfwcap.c | 35 | ||||
-rw-r--r-- | libavdevice/x11grab.c | 17 | ||||
-rw-r--r-- | libavdevice/xcbgrab.c | 11 | ||||
-rw-r--r-- | libavdevice/xv.c | 38 |
27 files changed, 226 insertions, 227 deletions
diff --git a/libavdevice/alsa.c b/libavdevice/alsa.c index 75ac444993..8d27913a1a 100644 --- a/libavdevice/alsa.c +++ b/libavdevice/alsa.c @@ -175,7 +175,7 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode, snd_pcm_t *h; snd_pcm_hw_params_t *hw_params; snd_pcm_uframes_t buffer_size, period_size; - uint64_t layout = ctx->streams[0]->codec->channel_layout; + uint64_t layout = ctx->streams[0]->codecpar->channel_layout; if (ctx->filename[0] == 0) audio_device = "default"; else audio_device = ctx->filename; diff --git a/libavdevice/alsa_dec.c b/libavdevice/alsa_dec.c index 71a6ef4f4e..c50ce71506 100644 --- a/libavdevice/alsa_dec.c +++ b/libavdevice/alsa_dec.c @@ -79,11 +79,11 @@ static av_cold int audio_read_header(AVFormatContext *s1) } /* take real parameters */ - st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->codec_id = codec_id; - st->codec->sample_rate = s->sample_rate; - st->codec->channels = s->channels; - st->codec->frame_size = s->frame_size; + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_id = codec_id; + st->codecpar->sample_rate = s->sample_rate; + st->codecpar->channels = s->channels; + st->codecpar->frame_size = s->frame_size; avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ /* microseconds instead of seconds, MHz instead of Hz */ s->timefilter = ff_timefilter_new(1000000.0 / s->sample_rate, diff --git a/libavdevice/alsa_enc.c b/libavdevice/alsa_enc.c index 10289a91a3..bddc61f4aa 100644 --- a/libavdevice/alsa_enc.c +++ b/libavdevice/alsa_enc.c @@ -55,20 +55,20 @@ static av_cold int audio_write_header(AVFormatContext *s1) enum AVCodecID codec_id; int res; - if (s1->nb_streams != 1 || s1->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO) { + if (s1->nb_streams != 1 || s1->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) { av_log(s1, AV_LOG_ERROR, "Only a single audio stream is supported.\n"); return AVERROR(EINVAL); } st = s1->streams[0]; - sample_rate = st->codec->sample_rate; - codec_id = st->codec->codec_id; + sample_rate = st->codecpar->sample_rate; + codec_id = st->codecpar->codec_id; res = ff_alsa_open(s1, SND_PCM_STREAM_PLAYBACK, &sample_rate, - st->codec->channels, &codec_id); - if (sample_rate != st->codec->sample_rate) { + st->codecpar->channels, &codec_id); + if (sample_rate != st->codecpar->sample_rate) { av_log(s1, AV_LOG_ERROR, "sample rate %d not available, nearest is %d\n", - st->codec->sample_rate, sample_rate); + st->codecpar->sample_rate, sample_rate); goto fail; } avpriv_set_pts_info(st, 64, 1, sample_rate); @@ -124,7 +124,7 @@ static int audio_write_frame(AVFormatContext *s1, int stream_index, /* ff_alsa_open() should have accepted only supported formats */ if ((flags & AV_WRITE_UNCODED_FRAME_QUERY)) - return av_sample_fmt_is_planar(s1->streams[stream_index]->codec->sample_fmt) ? + return av_sample_fmt_is_planar(s1->streams[stream_index]->codecpar->format) ? AVERROR(EINVAL) : 0; /* set only used fields */ pkt.data = (*frame)->data[0]; diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index c8a8953267..2902425b4d 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -286,14 +286,12 @@ static int grab_read_header(AVFormatContext *s1) s->per_frame = ((uint64_t)1000000 * framerate.den) / framerate.num; - st->codec->codec_type = AVMEDIA_TYPE_VIDEO; - st->codec->pix_fmt = AV_PIX_FMT_YUV420P; - st->codec->codec_id = AV_CODEC_ID_RAWVIDEO; - st->codec->width = s->width; - st->codec->height = s->height; - st->codec->time_base.den = framerate.num; - st->codec->time_base.num = framerate.den; - + st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + st->codecpar->format = AV_PIX_FMT_YUV420P; + st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; + st->codecpar->width = s->width; + st->codecpar->height = s->height; + st->avg_frame_rate = framerate; if (bktr_init(s1->filename, s->width, s->height, s->standard, &s->video_fd, &s->tuner_fd, -1, 0.0) < 0) { diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index f56c165539..678861da4b 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -918,7 +918,7 @@ dshow_add_device(AVFormatContext *avctx, { struct dshow_ctx *ctx = avctx->priv_data; AM_MEDIA_TYPE type; - AVCodecContext *codec; + AVCodecParameters *par; AVStream *st; int ret = AVERROR(EIO); @@ -933,7 +933,7 @@ dshow_add_device(AVFormatContext *avctx, libAVPin_ConnectionMediaType(ctx->capture_pin[devtype], &type); - codec = st->codec; + par = st->codecpar; if (devtype == VideoDevice) { BITMAPINFOHEADER *bih = NULL; AVRational time_base; @@ -952,33 +952,34 @@ dshow_add_device(AVFormatContext *avctx, goto error; } - codec->time_base = time_base; - codec->codec_type = AVMEDIA_TYPE_VIDEO; - codec->width = bih->biWidth; - codec->height = bih->biHeight; - codec->codec_tag = bih->biCompression; - codec->pix_fmt = dshow_pixfmt(bih->biCompression, bih->biBitCount); + st->avg_frame_rate = av_inv_q(time_base); + + par->codec_type = AVMEDIA_TYPE_VIDEO; + par->width = bih->biWidth; + par->height = bih->biHeight; + par->codec_tag = bih->biCompression; + par->format = dshow_pixfmt(bih->biCompression, bih->biBitCount); if (bih->biCompression == MKTAG('H', 'D', 'Y', 'C')) { av_log(avctx, AV_LOG_DEBUG, "attempt to use full range for HDYC...\n"); - codec->color_range = AVCOL_RANGE_MPEG; // just in case it needs this... + par->color_range = AVCOL_RANGE_MPEG; // just in case it needs this... } - if (codec->pix_fmt == AV_PIX_FMT_NONE) { + if (par->format == AV_PIX_FMT_NONE) { const AVCodecTag *const tags[] = { avformat_get_riff_video_tags(), NULL }; - codec->codec_id = av_codec_get_id(tags, bih->biCompression); - if (codec->codec_id == AV_CODEC_ID_NONE) { + par->codec_id = av_codec_get_id(tags, bih->biCompression); + if (par->codec_id == AV_CODEC_ID_NONE) { av_log(avctx, AV_LOG_ERROR, "Unknown compression type. " "Please report type 0x%X.\n", (int) bih->biCompression); return AVERROR_PATCHWELCOME; } - codec->bits_per_coded_sample = bih->biBitCount; + par->bits_per_coded_sample = bih->biBitCount; } else { - codec->codec_id = AV_CODEC_ID_RAWVIDEO; + par->codec_id = AV_CODEC_ID_RAWVIDEO; if (bih->biCompression == BI_RGB || bih->biCompression == BI_BITFIELDS) { - codec->bits_per_coded_sample = bih->biBitCount; - codec->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE); - if (codec->extradata) { - codec->extradata_size = 9; - memcpy(codec->extradata, "BottomUp", 9); + par->bits_per_coded_sample = bih->biBitCount; + par->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE); + if (par->extradata) { + par->extradata_size = 9; + memcpy(par->extradata, "BottomUp", 9); } } } @@ -993,11 +994,11 @@ dshow_add_device(AVFormatContext *avctx, goto error; } - codec->codec_type = AVMEDIA_TYPE_AUDIO; - codec->sample_fmt = sample_fmt_bits_per_sample(fx->wBitsPerSample); - codec->codec_id = waveform_codec_id(codec->sample_fmt); - codec->sample_rate = fx->nSamplesPerSec; - codec->channels = fx->nChannels; + par->codec_type = AVMEDIA_TYPE_AUDIO; + par->format = sample_fmt_bits_per_sample(fx->wBitsPerSample); + par->codec_id = waveform_codec_id(par->format); + par->sample_rate = fx->nSamplesPerSec; + par->channels = fx->nChannels; } avpriv_set_pts_info(st, 64, 1, 10000000); diff --git a/libavdevice/fbdev_dec.c b/libavdevice/fbdev_dec.c index e9a3639391..1505b2557d 100644 --- a/libavdevice/fbdev_dec.c +++ b/libavdevice/fbdev_dec.c @@ -126,13 +126,13 @@ static av_cold int fbdev_read_header(AVFormatContext *avctx) goto fail; } - st->codec->codec_type = AVMEDIA_TYPE_VIDEO; - st->codec->codec_id = AV_CODEC_ID_RAWVIDEO; - st->codec->width = fbdev->width; - st->codec->height = fbdev->height; - st->codec->pix_fmt = pix_fmt; - st->codec->time_base = av_inv_q(fbdev->framerate_q); - st->codec->bit_rate = + st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; + st->codecpar->width = fbdev->width; + st->codecpar->height = fbdev->height; + st->codecpar->format = pix_fmt; + st->avg_frame_rate = fbdev->framerate_q; + st->codecpar->bit_rate = fbdev->width * fbdev->height * fbdev->bytes_per_pixel * av_q2d(fbdev->framerate_q) * 8; av_log(avctx, AV_LOG_INFO, @@ -140,7 +140,7 @@ static av_cold int fbdev_read_header(AVFormatContext *avctx) fbdev->width, fbdev->height, fbdev->varinfo.bits_per_pixel, av_get_pix_fmt_name(pix_fmt), fbdev->framerate_q.num, fbdev->framerate_q.den, - (int64_t)st->codec->bit_rate); + (int64_t)st->codecpar->bit_rate); return 0; fail: diff --git a/libavdevice/fbdev_enc.c b/libavdevice/fbdev_enc.c index 28efc7131b..b4e5f84975 100644 --- a/libavdevice/fbdev_enc.c +++ b/libavdevice/fbdev_enc.c @@ -48,7 +48,7 @@ static av_cold int fbdev_write_header(AVFormatContext *h) int ret, flags = O_RDWR; const char* device; - if (h->nb_streams != 1 || h->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO) { + if (h->nb_streams != 1 || h->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) { av_log(fbdev, AV_LOG_ERROR, "Only a single video stream is supported.\n"); return AVERROR(EINVAL); } @@ -105,11 +105,11 @@ static int fbdev_write_packet(AVFormatContext *h, AVPacket *pkt) enum AVPixelFormat fb_pix_fmt; int disp_height; int bytes_to_copy; - AVCodecContext *codec_ctx = h->streams[0]->codec; - enum AVPixelFormat video_pix_fmt = codec_ctx->pix_fmt; - int video_width = codec_ctx->width; - int video_height = codec_ctx->height; - int bytes_per_pixel = ((codec_ctx->bits_per_coded_sample + 7) >> 3); + AVCodecParameters *par = h->streams[0]->codecpar; + enum AVPixelFormat video_pix_fmt = par->format; + int video_width = par->width; + int video_height = par->height; + int bytes_per_pixel = ((par->bits_per_coded_sample + 7) >> 3); int src_line_size = video_width * bytes_per_pixel; int i; diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c index 7db587cd97..4239ffae11 100644 --- a/libavdevice/gdigrab.c +++ b/libavdevice/gdigrab.c @@ -403,10 +403,11 @@ gdigrab_read_header(AVFormatContext *s1) } } - st->codec->codec_type = AVMEDIA_TYPE_VIDEO; - st->codec->codec_id = AV_CODEC_ID_BMP; - st->codec->time_base = gdigrab->time_base; - st->codec->bit_rate = (gdigrab->header_size + gdigrab->frame_size) * 1/av_q2d(gdigrab->time_base) * 8; + st->avg_frame_rate = av_inv_q(gdigrab->time_base); + + st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + st->codecpar->codec_id = AV_CODEC_ID_BMP; + st->codecpar->bit_rate = (gdigrab->header_size + gdigrab->frame_size) * 1/av_q2d(gdigrab->time_base) * 8; return 0; diff --git a/libavdevice/jack.c b/libavdevice/jack.c index 545548423d..34e21527a7 100644 --- a/libavdevice/jack.c +++ b/libavdevice/jack.c @@ -262,14 +262,14 @@ static int audio_read_header(AVFormatContext *context) return AVERROR(ENOMEM); } - stream->codec->codec_type = AVMEDIA_TYPE_AUDIO; + stream->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; #if HAVE_BIGENDIAN - stream->codec->codec_id = AV_CODEC_ID_PCM_F32BE; + stream->codecpar->codec_id = AV_CODEC_ID_PCM_F32BE; #else - stream->codec->codec_id = AV_CODEC_ID_PCM_F32LE; + stream->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE; #endif - stream->codec->sample_rate = self->sample_rate; - stream->codec->channels = self->nports; + stream->codecpar->sample_rate = self->sample_rate; + stream->codecpar->channels = self->nports; avpriv_set_pts_info(stream, 64, 1, 1000000); /* 64 bits pts in us */ return 0; diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index 8e9e67d3c2..a52d4730e5 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -108,8 +108,8 @@ static int create_subcc_streams(AVFormatContext *avctx) lavfi->sink_stream_subcc_map[sink_idx] = avctx->nb_streams; if (!(st = avformat_new_stream(avctx, NULL))) return AVERROR(ENOMEM); - st->codec->codec_id = AV_CODEC_ID_EIA_608; - st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE; + st->codecpar->codec_id = AV_CODEC_ID_EIA_608; + st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE; } else { lavfi->sink_stream_subcc_map[sink_idx] = -1; } @@ -314,28 +314,28 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) for (i = 0; i < lavfi->nb_sinks; i++) { AVFilterLink *link = lavfi->sinks[lavfi->stream_sink_map[i]]->inputs[0]; AVStream *st = avctx->streams[i]; - st->codec->codec_type = link->type; + st->codecpar->codec_type = link->type; avpriv_set_pts_info(st, 64, link->time_base.num, link->time_base.den); if (link->type == AVMEDIA_TYPE_VIDEO) { - st->codec->codec_id = AV_CODEC_ID_RAWVIDEO; - st->codec->pix_fmt = link->format; - st->codec->time_base = link->time_base; - st->codec->width = link->w; - st->codec->height = link->h; + st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; + st->codecpar->format = link->format; + st->avg_frame_rate = av_inv_q(link->time_base); + st->codecpar->width = link->w; + st->codecpar->height = link->h; st ->sample_aspect_ratio = - st->codec->sample_aspect_ratio = link->sample_aspect_ratio; + st->codecpar->sample_aspect_ratio = link->sample_aspect_ratio; avctx->probesize = FFMAX(avctx->probesize, link->w * link->h * av_get_padded_bits_per_pixel(av_pix_fmt_desc_get(link->format)) * 30); } else if (link->type == AVMEDIA_TYPE_AUDIO) { - st->codec->codec_id = av_get_pcm_codec(link->format, -1); - st->codec->channels = avfilter_link_get_channels(link); - st->codec->sample_fmt = link->format; - st->codec->sample_rate = link->sample_rate; - st->codec->time_base = link->time_base; - st->codec->channel_layout = link->channel_layout; - if (st->codec->codec_id == AV_CODEC_ID_NONE) + st->codecpar->codec_id = av_get_pcm_codec(link->format, -1); + st->codecpar->channels = avfilter_link_get_channels(link); + st->codecpar->format = link->format; + st->codecpar->sample_rate = link->sample_rate; + st->avg_frame_rate = av_inv_q(link->time_base); + st->codecpar->channel_layout = link->channel_layout; + if (st->codecpar->codec_id == AV_CODEC_ID_NONE) av_log(avctx, AV_LOG_ERROR, "Could not find PCM codec for sample format %s.\n", av_get_sample_fmt_name(link->format)); diff --git a/libavdevice/libcdio.c b/libavdevice/libcdio.c index 9e9b0d86f3..f6d4fce256 100644 --- a/libavdevice/libcdio.c +++ b/libavdevice/libcdio.c @@ -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]; diff --git a/libavdevice/libdc1394.c b/libavdevice/libdc1394.c index dcdca6064f..43fa232922 100644 --- a/libavdevice/libdc1394.c +++ b/libavdevice/libdc1394.c @@ -171,13 +171,12 @@ static inline int dc1394_read_common(AVFormatContext *c, goto out; } avpriv_set_pts_info(vst, 64, 1, 1000); - vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; - vst->codec->codec_id = AV_CODEC_ID_RAWVIDEO; - vst->codec->time_base.den = framerate.num; - vst->codec->time_base.num = framerate.den; - vst->codec->width = fmt->width; - vst->codec->height = fmt->height; - vst->codec->pix_fmt = fmt->pix_fmt; + vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + vst->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; + vst->codecpar->width = fmt->width; + vst->codecpar->height = fmt->height; + vst->codecpar->format = fmt->pix_fmt; + vst->avg_frame_rate = framerate; /* packet init */ av_init_packet(&dc1394->packet); @@ -188,7 +187,7 @@ static inline int dc1394_read_common(AVFormatContext *c, dc1394->current_frame = 0; - vst->codec->bit_rate = av_rescale(dc1394->packet.size * 8, fps->frame_rate, 1000); + vst->codecpar->bit_rate = av_rescale(dc1394->packet.size * 8, fps->frame_rate, 1000); *select_fps = fps; *select_fmt = fmt; out: diff --git a/libavdevice/openal-dec.c b/libavdevice/openal-dec.c index e4daf53250..0647952f9c 100644 --- a/libavdevice/openal-dec.c +++ b/libavdevice/openal-dec.c @@ -128,7 +128,7 @@ static int read_header(AVFormatContext *ctx) int error = 0; const char *error_msg; AVStream *st = NULL; - AVCodecContext *codec = NULL; + AVCodecParameters *par = NULL; if (ad->list_devices) { print_al_capture_devices(ctx); @@ -156,11 +156,11 @@ static int read_header(AVFormatContext *ctx) avpriv_set_pts_info(st, 64, 1, 1000000); /* Set codec parameters */ - codec = st->codec; - codec->codec_type = AVMEDIA_TYPE_AUDIO; - codec->sample_rate = ad->sample_rate; - codec->channels = get_al_format_info(ad->sample_format)->channels; - codec->codec_id = get_al_format_info(ad->sample_format)->codec_id; + par = st->codecpar; + par->codec_type = AVMEDIA_TYPE_AUDIO; + par->sample_rate = ad->sample_rate; + par->channels = get_al_format_info(ad->sample_format)->channels; + par->codec_id = get_al_format_info(ad->sample_format)->codec_id; /* This is needed to read the audio data */ ad->sample_step = (av_get_bits_per_sample(get_al_format_info(ad->sample_format)->codec_id) * diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c index ba8d36abff..1dbbb80f44 100644 --- a/libavdevice/opengl_enc.c +++ b/libavdevice/opengl_enc.c @@ -678,11 +678,11 @@ static void opengl_compute_display_area(AVFormatContext *s) AVRational sar, dar; /* sample and display aspect ratios */ OpenGLContext *opengl = s->priv_data; AVStream *st = s->streams[0]; - AVCodecContext *encctx = st->codec; + AVCodecParameters *par = st->codecpar; /* compute overlay width and height from the codec context information */ sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 }; - dar = av_mul_q(sar, (AVRational){ encctx->width, encctx->height }); + dar = av_mul_q(sar, (AVRational){ par->width, par->height }); /* we suppose the screen has a 1/1 sample aspect ratio */ /* fit in the window */ @@ -1065,15 +1065,15 @@ static av_cold int opengl_write_header(AVFormatContext *h) int ret; if (h->nb_streams != 1 || - h->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO || - h->streams[0]->codec->codec_id != AV_CODEC_ID_RAWVIDEO) { + h->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO || + h->streams[0]->codecpar->codec_id != AV_CODEC_ID_RAWVIDEO) { av_log(opengl, AV_LOG_ERROR, "Only a single video stream is supported.\n"); return AVERROR(EINVAL); } st = h->streams[0]; - opengl->width = st->codec->width; - opengl->height = st->codec->height; - opengl->pix_fmt = st->codec->pix_fmt; + opengl->width = st->codecpar->width; + opengl->height = st->codecpar->height; + opengl->pix_fmt = st->codecpar->format; if (!opengl->window_width) opengl->window_width = opengl->width; if (!opengl->window_height) @@ -1200,7 +1200,7 @@ static uint8_t* opengl_get_plane_pointer(OpenGLContext *opengl, AVPacket *pkt, i static int opengl_draw(AVFormatContext *h, void *input, int repaint, int is_pkt) { OpenGLContext *opengl = h->priv_data; - enum AVPixelFormat pix_fmt = h->streams[0]->codec->pix_fmt; + enum AVPixelFormat pix_fmt = h->streams[0]->codecpar->format; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); int ret; diff --git a/libavdevice/oss_dec.c b/libavdevice/oss_dec.c index 3a9a20a233..9f748f2bc3 100644 --- a/libavdevice/oss_dec.c +++ b/libavdevice/oss_dec.c @@ -63,10 +63,10 @@ static int audio_read_header(AVFormatContext *s1) } /* take real parameters */ - st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->codec_id = s->codec_id; - st->codec->sample_rate = s->sample_rate; - st->codec->channels = s->channels; + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_id = s->codec_id; + st->codecpar->sample_rate = s->sample_rate; + st->codecpar->channels = s->channels; avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ return 0; diff --git a/libavdevice/oss_enc.c b/libavdevice/oss_enc.c index 3781eb54e5..2268b4cfe4 100644 --- a/libavdevice/oss_enc.c +++ b/libavdevice/oss_enc.c @@ -49,8 +49,8 @@ static int audio_write_header(AVFormatContext *s1) int ret; st = s1->streams[0]; - s->sample_rate = st->codec->sample_rate; - s->channels = st->codec->channels; + s->sample_rate = st->codecpar->sample_rate; + s->channels = st->codecpar->channels; ret = ff_oss_audio_open(s1, 1, s1->filename); if (ret < 0) { return AVERROR(EIO); diff --git a/libavdevice/pulse_audio_dec.c b/libavdevice/pulse_audio_dec.c index aa0800b40b..95a1d6ecfa 100644 --- a/libavdevice/pulse_audio_dec.c +++ b/libavdevice/pulse_audio_dec.c @@ -242,10 +242,10 @@ static av_cold int pulse_read_header(AVFormatContext *s) pa_threaded_mainloop_unlock(pd->mainloop); /* take real parameters */ - st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->codec_id = codec_id; - st->codec->sample_rate = pd->sample_rate; - st->codec->channels = pd->channels; + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_id = codec_id; + st->codecpar->sample_rate = pd->sample_rate; + st->codecpar->channels = pd->channels; avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ pd->timefilter = ff_timefilter_new(1000000.0 / pd->sample_rate, diff --git a/libavdevice/pulse_audio_enc.c b/libavdevice/pulse_audio_enc.c index b419a38d46..6fb634ee2b 100644 --- a/libavdevice/pulse_audio_enc.c +++ b/libavdevice/pulse_audio_enc.c @@ -452,7 +452,7 @@ static av_cold int pulse_write_header(AVFormatContext *h) PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_NOT_MONOTONIC; - if (h->nb_streams != 1 || h->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO) { + if (h->nb_streams != 1 || h->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) { av_log(s, AV_LOG_ERROR, "Only a single audio stream is supported.\n"); return AVERROR(EINVAL); } @@ -468,8 +468,8 @@ static av_cold int pulse_write_header(AVFormatContext *h) if (s->buffer_duration) { int64_t bytes = s->buffer_duration; - bytes *= st->codec->channels * st->codec->sample_rate * - av_get_bytes_per_sample(st->codec->sample_fmt); + bytes *= st->codecpar->channels * st->codecpar->sample_rate * + av_get_bytes_per_sample(st->codecpar->format); bytes /= 1000; buffer_attributes.tlength = FFMAX(s->buffer_size, av_clip64(bytes, 0, UINT32_MAX - 1)); av_log(s, AV_LOG_DEBUG, @@ -483,9 +483,9 @@ static av_cold int pulse_write_header(AVFormatContext *h) if (s->minreq) buffer_attributes.minreq = s->minreq; - sample_spec.format = ff_codec_id_to_pulse_format(st->codec->codec_id); - sample_spec.rate = st->codec->sample_rate; - sample_spec.channels = st->codec->channels; + sample_spec.format = ff_codec_id_to_pulse_format(st->codecpar->codec_id); + sample_spec.rate = st->codecpar->sample_rate; + sample_spec.channels = st->codecpar->channels; if (!pa_sample_spec_valid(&sample_spec)) { av_log(s, AV_LOG_ERROR, "Invalid sample spec.\n"); return AVERROR(EINVAL); @@ -494,10 +494,10 @@ static av_cold int pulse_write_header(AVFormatContext *h) if (sample_spec.channels == 1) { channel_map.channels = 1; channel_map.map[0] = PA_CHANNEL_POSITION_MONO; - } else if (st->codec->channel_layout) { - if (av_get_channel_layout_nb_channels(st->codec->channel_layout) != st->codec->channels) + } else if (st->codecpar->channel_layout) { + if (av_get_channel_layout_nb_channels(st->codecpar->channel_layout) != st->codecpar->channels) return AVERROR(EINVAL); - pulse_map_channels_to_pulse(st->codec->channel_layout, &channel_map); + pulse_map_channels_to_pulse(st->codecpar->channel_layout, &channel_map); /* Unknown channel is present in channel_layout, let PulseAudio use its default. */ if (channel_map.channels != sample_spec.channels) { av_log(s, AV_LOG_WARNING, "Unknown channel. Using defaul channel map.\n"); @@ -637,9 +637,8 @@ static int pulse_write_packet(AVFormatContext *h, AVPacket *pkt) s->timestamp += pkt->duration; } else { AVStream *st = h->streams[0]; - AVCodecContext *codec_ctx = st->codec; - AVRational r = { 1, codec_ctx->sample_rate }; - int64_t samples = pkt->size / (av_get_bytes_per_sample(codec_ctx->sample_fmt) * codec_ctx->channels); + AVRational r = { 1, st->codecpar->sample_rate }; + int64_t samples = pkt->size / (av_get_bytes_per_sample(st->codecpar->format) * st->codecpar->channels); s->timestamp += av_rescale_q(samples, r, st->time_base); } @@ -678,7 +677,7 @@ static int pulse_write_frame(AVFormatContext *h, int stream_index, /* Planar formats are not supported yet. */ if (flags & AV_WRITE_UNCODED_FRAME_QUERY) - return av_sample_fmt_is_planar(h->streams[stream_index]->codec->sample_fmt) ? + return av_sample_fmt_is_planar(h->streams[stream_index]->codecpar->format) ? AVERROR(EINVAL) : 0; pkt.data = (*frame)->data[0]; diff --git a/libavdevice/sdl.c b/libavdevice/sdl.c index 4cccfe528a..432275004c 100644 --- a/libavdevice/sdl.c +++ b/libavdevice/sdl.c @@ -94,12 +94,12 @@ static void compute_overlay_rect(AVFormatContext *s) AVRational sar, dar; /* sample and display aspect ratios */ SDLContext *sdl = s->priv_data; AVStream *st = s->streams[0]; - AVCodecContext *encctx = st->codec; + AVCodecParameters *par = st->codecpar; SDL_Rect *overlay_rect = &sdl->overlay_rect; /* compute overlay width and height from the codec context information */ sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 }; - dar = av_mul_q(sar, (AVRational){ encctx->width, encctx->height }); + dar = av_mul_q(sar, (AVRational){ par->width, par->height }); /* we suppose the screen has a 1/1 sample aspect ratio */ if (sdl->window_width && sdl->window_height) { @@ -115,10 +115,10 @@ static void compute_overlay_rect(AVFormatContext *s) } } else { if (sar.num > sar.den) { - overlay_rect->w = encctx->width; + overlay_rect->w = par->width; overlay_rect->h = av_rescale(overlay_rect->w, dar.den, dar.num); } else { - overlay_rect->h = encctx->height; + overlay_rect->h = par->height; overlay_rect->w = av_rescale(overlay_rect->h, dar.num, dar.den); } sdl->window_width = overlay_rect->w; @@ -137,7 +137,7 @@ static int event_thread(void *arg) SDLContext *sdl = s->priv_data; int flags = SDL_BASE_FLAGS | (sdl->window_fullscreen ? SDL_FULLSCREEN : 0); AVStream *st = s->streams[0]; - AVCodecContext *encctx = st->codec; + AVCodecParameters *par = st->codecpar; /* initialization */ if (SDL_Init(SDL_INIT_VIDEO) != 0) { @@ -155,19 +155,19 @@ static int event_thread(void *arg) goto init_end; } - sdl->overlay = SDL_CreateYUVOverlay(encctx->width, encctx->height, + sdl->overlay = SDL_CreateYUVOverlay(par->width, par->height, sdl->overlay_fmt, sdl->surface); - if (!sdl->overlay || sdl->overlay->pitches[0] < encctx->width) { + if (!sdl->overlay || sdl->overlay->pitches[0] < par->width) { av_log(s, AV_LOG_ERROR, "SDL does not support an overlay with size of %dx%d pixels\n", - encctx->width, encctx->height); + par->width, par->height); sdl->init_ret = AVERROR(EINVAL); goto init_end; } sdl->init_ret = 0; av_log(s, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s -> w:%d h:%d\n", - encctx->width, encctx->height, av_get_pix_fmt_name(encctx->pix_fmt), + par->width, par->height, av_get_pix_fmt_name(par->format), sdl->overlay_rect.w, sdl->overlay_rect.h); init_end: @@ -234,7 +234,7 @@ static int sdl_write_header(AVFormatContext *s) { SDLContext *sdl = s->priv_data; AVStream *st = s->streams[0]; - AVCodecContext *encctx = st->codec; + AVCodecParameters *par = st->codecpar; int i, ret; if (!sdl->window_title) @@ -251,15 +251,15 @@ static int sdl_write_header(AVFormatContext *s) } if ( s->nb_streams > 1 - || encctx->codec_type != AVMEDIA_TYPE_VIDEO - || encctx->codec_id != AV_CODEC_ID_RAWVIDEO) { + || par->codec_type != AVMEDIA_TYPE_VIDEO + || par->codec_id != AV_CODEC_ID_RAWVIDEO) { av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n"); ret = AVERROR(EINVAL); goto fail; } for (i = 0; sdl_overlay_pix_fmt_map[i].pix_fmt != AV_PIX_FMT_NONE; i++) { - if (sdl_overlay_pix_fmt_map[i].pix_fmt == encctx->pix_fmt) { + if (sdl_overlay_pix_fmt_map[i].pix_fmt == par->format) { sdl->overlay_fmt = sdl_overlay_pix_fmt_map[i].overlay_fmt; break; } @@ -268,7 +268,7 @@ static int sdl_write_header(AVFormatContext *s) if (!sdl->overlay_fmt) { av_log(s, AV_LOG_ERROR, "Unsupported pixel format '%s', choose one of yuv420p, yuyv422, or uyvy422\n", - av_get_pix_fmt_name(encctx->pix_fmt)); + av_get_pix_fmt_name(par->format)); ret = AVERROR(EINVAL); goto fail; } @@ -315,7 +315,7 @@ fail: static int sdl_write_packet(AVFormatContext *s, AVPacket *pkt) { SDLContext *sdl = s->priv_data; - AVCodecContext *encctx = s->streams[0]->codec; + AVCodecParameters *par = s->streams[0]->codecpar; uint8_t *data[4]; int linesize[4]; int i; @@ -324,7 +324,7 @@ static int sdl_write_packet(AVFormatContext *s, AVPacket *pkt) sdl_write_trailer(s); return AVERROR(EIO); } - av_image_fill_arrays(data, linesize, pkt->data, encctx->pix_fmt, encctx->width, encctx->height, 1); + av_image_fill_arrays(data, linesize, pkt->data, par->format, par->width, par->height, 1); SDL_LockMutex(sdl->mutex); SDL_FillRect(sdl->surface, &sdl->surface->clip_rect, diff --git a/libavdevice/sndio_dec.c b/libavdevice/sndio_dec.c index 6f1160e0f0..2d13232bf1 100644 --- a/libavdevice/sndio_dec.c +++ b/libavdevice/sndio_dec.c @@ -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 */ diff --git a/libavdevice/sndio_enc.c b/libavdevice/sndio_enc.c index 52b9060ef6..47f500d71e 100644 --- a/libavdevice/sndio_enc.c +++ b/libavdevice/sndio_enc.c @@ -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); diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index 383033e738..103fb105f2 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -938,8 +938,8 @@ static int v4l2_read_header(AVFormatContext *ctx) if ((res = v4l2_set_parameters(ctx)) < 0) goto fail; - st->codec->pix_fmt = ff_fmt_v4l2ff(desired_format, codec_id); - s->frame_size = av_image_get_buffer_size(st->codec->pix_fmt, + st->codecpar->format = ff_fmt_v4l2ff(desired_format, codec_id); + s->frame_size = av_image_get_buffer_size(st->codecpar->format, s->width, s->height, 1); if ((res = mmap_init(ctx)) || @@ -948,22 +948,22 @@ static int v4l2_read_header(AVFormatContext *ctx) s->top_field_first = first_field(s); - st->codec->codec_type = AVMEDIA_TYPE_VIDEO; - st->codec->codec_id = codec_id; + st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + st->codecpar->codec_id = codec_id; if (codec_id == AV_CODEC_ID_RAWVIDEO) - st->codec->codec_tag = - avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt); + st->codecpar->codec_tag = + avcodec_pix_fmt_to_codec_tag(st->codecpar->format); else if (codec_id == AV_CODEC_ID_H264) { st->need_parsing = AVSTREAM_PARSE_FULL_ONCE; } if (desired_format == V4L2_PIX_FMT_YVU420) - st->codec->codec_tag = MKTAG('Y', 'V', '1', '2'); + st->codecpar->codec_tag = MKTAG('Y', 'V', '1', '2'); else if (desired_format == V4L2_PIX_FMT_YVU410) - st->codec->codec_tag = MKTAG('Y', 'V', 'U', '9'); - st->codec->width = s->width; - st->codec->height = s->height; + st->codecpar->codec_tag = MKTAG('Y', 'V', 'U', '9'); + st->codecpar->width = s->width; + st->codecpar->height = s->height; if (st->avg_frame_rate.den) - st->codec->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8; + st->codecpar->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8; return 0; diff --git a/libavdevice/v4l2enc.c b/libavdevice/v4l2enc.c index ac4068cbd4..faf6e07f86 100644 --- a/libavdevice/v4l2enc.c +++ b/libavdevice/v4l2enc.c @@ -33,7 +33,7 @@ static av_cold int write_header(AVFormatContext *s1) .type = V4L2_BUF_TYPE_VIDEO_OUTPUT }; V4L2Context *s = s1->priv_data; - AVCodecContext *enc_ctx; + AVCodecParameters *par; uint32_t v4l2_pixfmt; if (s1->flags & AVFMT_FLAG_NONBLOCK) @@ -47,19 +47,19 @@ static av_cold int write_header(AVFormatContext *s1) } if (s1->nb_streams != 1 || - s1->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO || - s1->streams[0]->codec->codec_id != AV_CODEC_ID_RAWVIDEO) { + s1->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO || + s1->streams[0]->codecpar->codec_id != AV_CODEC_ID_RAWVIDEO) { av_log(s1, AV_LOG_ERROR, "V4L2 output device supports only a single raw video stream\n"); return AVERROR(EINVAL); } - enc_ctx = s1->streams[0]->codec; + par = s1->streams[0]->codecpar; - v4l2_pixfmt = ff_fmt_ff2v4l(enc_ctx->pix_fmt, AV_CODEC_ID_RAWVIDEO); + v4l2_pixfmt = ff_fmt_ff2v4l(par->format, AV_CODEC_ID_RAWVIDEO); if (!v4l2_pixfmt) { // XXX: try to force them one by one? av_log(s1, AV_LOG_ERROR, "Unknown V4L2 pixel format equivalent for %s\n", - av_get_pix_fmt_name(enc_ctx->pix_fmt)); + av_get_pix_fmt_name(par->format)); return AVERROR(EINVAL); } @@ -69,10 +69,10 @@ static av_cold int write_header(AVFormatContext *s1) return res; } - fmt.fmt.pix.width = enc_ctx->width; - fmt.fmt.pix.height = enc_ctx->height; + fmt.fmt.pix.width = par->width; + fmt.fmt.pix.height = par->height; fmt.fmt.pix.pixelformat = v4l2_pixfmt; - fmt.fmt.pix.sizeimage = av_image_get_buffer_size(enc_ctx->pix_fmt, enc_ctx->width, enc_ctx->height, 1); + fmt.fmt.pix.sizeimage = av_image_get_buffer_size(par->format, par->width, par->height, 1); if (ioctl(s->fd, VIDIOC_S_FMT, &fmt) < 0) { res = AVERROR(errno); diff --git a/libavdevice/vfwcap.c b/libavdevice/vfwcap.c index e1f8b86699..2dcf5aa2ed 100644 --- a/libavdevice/vfwcap.c +++ b/libavdevice/vfwcap.c @@ -245,7 +245,7 @@ static int vfw_read_close(AVFormatContext *s) static int vfw_read_header(AVFormatContext *s) { struct vfw_ctx *ctx = s->priv_data; - AVCodecContext *codec; + AVCodecParameters *par; AVStream *st; int devnum; int bisize; @@ -377,29 +377,30 @@ static int vfw_read_header(AVFormatContext *s) if(!ret) goto fail; - codec = st->codec; - codec->time_base = av_inv_q(framerate_q); - codec->codec_type = AVMEDIA_TYPE_VIDEO; - codec->width = bi->bmiHeader.biWidth; - codec->height = bi->bmiHeader.biHeight; - codec->pix_fmt = vfw_pixfmt(biCompression, biBitCount); - if(codec->pix_fmt == AV_PIX_FMT_NONE) { - codec->codec_id = vfw_codecid(biCompression); - if(codec->codec_id == AV_CODEC_ID_NONE) { + st->avg_frame_rate = framerate_q; + + par = st->codecpar; + par->codec_type = AVMEDIA_TYPE_VIDEO; + par->width = bi->bmiHeader.biWidth; + par->height = bi->bmiHeader.biHeight; + par->format = vfw_pixfmt(biCompression, biBitCount); + if (par->format == AV_PIX_FMT_NONE) { + par->codec_id = vfw_codecid(biCompression); + if (par->codec_id == AV_CODEC_ID_NONE) { av_log(s, AV_LOG_ERROR, "Unknown compression type. " "Please report verbose (-v 9) debug information.\n"); vfw_read_close(s); return AVERROR_PATCHWELCOME; } - codec->bits_per_coded_sample = biBitCount; + par->bits_per_coded_sample = biBitCount; } else { - codec->codec_id = AV_CODEC_ID_RAWVIDEO; + par->codec_id = AV_CODEC_ID_RAWVIDEO; if(biCompression == BI_RGB) { - codec->bits_per_coded_sample = biBitCount; - codec->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE); - if (codec->extradata) { - codec->extradata_size = 9; - memcpy(codec->extradata, "BottomUp", 9); + par->bits_per_coded_sample = biBitCount; + par->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE); + if (par->extradata) { + par->extradata_size = 9; + memcpy(par->extradata, "BottomUp", 9); } } } diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c index 9dc3472187..a78e7a47a6 100644 --- a/libavdevice/x11grab.c +++ b/libavdevice/x11grab.c @@ -355,11 +355,11 @@ static int x11grab_read_header(AVFormatContext *s1) x11grab->image = image; x11grab->use_shm = use_shm; - ret = pixfmt_from_image(s1, image, &st->codec->pix_fmt); + ret = pixfmt_from_image(s1, image, &st->codecpar->format); if (ret < 0) goto out; - if (st->codec->pix_fmt == AV_PIX_FMT_PAL8) { + if (st->codecpar->format == AV_PIX_FMT_PAL8) { color_map = DefaultColormap(dpy, screen); for (i = 0; i < 256; ++i) color[i].pixel = i; @@ -372,12 +372,13 @@ static int x11grab_read_header(AVFormatContext *s1) } - st->codec->codec_type = AVMEDIA_TYPE_VIDEO; - st->codec->codec_id = AV_CODEC_ID_RAWVIDEO; - st->codec->width = x11grab->width; - st->codec->height = x11grab->height; - st->codec->time_base = x11grab->time_base; - st->codec->bit_rate = x11grab->frame_size * 1 / av_q2d(x11grab->time_base) * 8; + st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; + st->codecpar->width = x11grab->width; + st->codecpar->height = x11grab->height; + st->codecpar->bit_rate = x11grab->frame_size * 1 / av_q2d(x11grab->time_base) * 8; + + st->avg_frame_rate = av_inv_q(x11grab->time_base); out: av_free(dpyname); diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c index 2da7ec7d4f..9da46c8e0d 100644 --- a/libavdevice/xcbgrab.c +++ b/libavdevice/xcbgrab.c @@ -548,13 +548,12 @@ static int create_stream(AVFormatContext *s) st->avg_frame_rate.num }; c->time_frame = av_gettime(); - st->codec->codec_type = AVMEDIA_TYPE_VIDEO; - st->codec->codec_id = AV_CODEC_ID_RAWVIDEO; - st->codec->width = c->width; - st->codec->height = c->height; - st->codec->time_base = c->time_base; + st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; + st->codecpar->width = c->width; + st->codecpar->height = c->height; - ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codec->pix_fmt); + ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codecpar->format); free(geo); diff --git a/libavdevice/xv.c b/libavdevice/xv.c index 64cddeb068..185de7569e 100644 --- a/libavdevice/xv.c +++ b/libavdevice/xv.c @@ -109,22 +109,22 @@ static int xv_write_header(AVFormatContext *s) XColor fgcolor; XWindowAttributes window_attrs; int num_formats = 0, j, tag, ret; - AVCodecContext *encctx = s->streams[0]->codec; + AVCodecParameters *par = s->streams[0]->codecpar; if ( s->nb_streams > 1 - || encctx->codec_type != AVMEDIA_TYPE_VIDEO - || encctx->codec_id != AV_CODEC_ID_RAWVIDEO) { + || par->codec_type != AVMEDIA_TYPE_VIDEO + || par->codec_id != AV_CODEC_ID_RAWVIDEO) { av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n"); return AVERROR(EINVAL); } - if (!(tag = xv_get_tag_from_format(encctx->pix_fmt))) { + if (!(tag = xv_get_tag_from_format(par->format))) { av_log(s, AV_LOG_ERROR, "Unsupported pixel format '%s', only yuv420p, uyvy422, yuyv422 are currently supported\n", - av_get_pix_fmt_name(encctx->pix_fmt)); + av_get_pix_fmt_name(par->format)); return AVERROR_PATCHWELCOME; } - xv->image_format = encctx->pix_fmt; + xv->image_format = par->format; xv->display = XOpenDisplay(xv->display_name); if (!xv->display) { @@ -132,12 +132,12 @@ static int xv_write_header(AVFormatContext *s) return AVERROR(EINVAL); } - xv->image_width = encctx->width; - xv->image_height = encctx->height; + xv->image_width = par->width; + xv->image_height = par->height; if (!xv->window_width && !xv->window_height) { - AVRational sar = encctx->sample_aspect_ratio; - xv->window_width = encctx->width; - xv->window_height = encctx->height; + AVRational sar = par->sample_aspect_ratio; + xv->window_width = par->width; + xv->window_height = par->height; if (sar.num) { if (sar.num > sar.den) xv->window_width = av_rescale(xv->window_width, sar.num, sar.den); @@ -189,14 +189,14 @@ static int xv_write_header(AVFormatContext *s) if (j >= num_formats) { av_log(s, AV_LOG_ERROR, "Device does not support pixel format %s, aborting\n", - av_get_pix_fmt_name(encctx->pix_fmt)); + av_get_pix_fmt_name(par->format)); ret = AVERROR(EINVAL); goto fail; } xv->gc = XCreateGC(xv->display, xv->window, 0, 0); - xv->image_width = encctx->width; - xv->image_height = encctx->height; + xv->image_width = par->width; + xv->image_height = par->height; xv->yuv_image = XvShmCreateImage(xv->display, xv->xv_port, tag, 0, xv->image_width, xv->image_height, &xv->yuv_shminfo); xv->yuv_shminfo.shmid = shmget(IPC_PRIVATE, xv->yuv_image->data_size, @@ -228,11 +228,11 @@ static void compute_display_area(AVFormatContext *s) XVContext *xv = s->priv_data; AVRational sar, dar; /* sample and display aspect ratios */ AVStream *st = s->streams[0]; - AVCodecContext *encctx = st->codec; + AVCodecParameters *par = st->codecpar; /* compute overlay width and height from the codec context information */ sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 }; - dar = av_mul_q(sar, (AVRational){ encctx->width, encctx->height }); + dar = av_mul_q(sar, (AVRational){ par->width, par->height }); /* we suppose the screen has a 1/1 sample aspect ratio */ /* fit in the window */ @@ -321,12 +321,12 @@ static int write_picture(AVFormatContext *s, uint8_t *input_data[4], static int xv_write_packet(AVFormatContext *s, AVPacket *pkt) { - AVCodecContext *ctx = s->streams[0]->codec; + AVCodecParameters *par = s->streams[0]->codecpar; uint8_t *data[4]; int linesize[4]; - av_image_fill_arrays(data, linesize, pkt->data, ctx->pix_fmt, - ctx->width, ctx->height, 1); + av_image_fill_arrays(data, linesize, pkt->data, par->format, + par->width, par->height, 1); return write_picture(s, data, linesize); } |