#include "libavutil/imgutils.h"
#include "libavutil/samplefmt.h"
-enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodec *codec, enum AVPixelFormat target)
+enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx, AVCodec *codec, enum AVPixelFormat target)
{
if (codec && codec->pix_fmts) {
const enum AVPixelFormat *p = codec->pix_fmts;
{ AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P,
AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_BGRA, AV_PIX_FMT_NONE };
- if (st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
- if (st->codec->codec_id == AV_CODEC_ID_MJPEG) {
+ if (enc_ctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
+ if (enc_ctx->codec_id == AV_CODEC_ID_MJPEG) {
p = mjpeg_formats;
- } else if (st->codec->codec_id == AV_CODEC_ID_LJPEG) {
+ } else if (enc_ctx->codec_id == AV_CODEC_ID_LJPEG) {
p =ljpeg_formats;
}
}
AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
if (strict_dict)
// used by choose_pixel_fmt() and below
- av_opt_set(ost->st->codec, "strict", strict_dict->value, 0);
+ av_opt_set(ost->enc_ctx, "strict", strict_dict->value, 0);
if (ost->keep_pix_fmt) {
if (ost->filter)
avfilter_graph_set_auto_convert(ost->filter->graph->graph,
AVFILTER_AUTO_CONVERT_NONE);
- if (ost->st->codec->pix_fmt == AV_PIX_FMT_NONE)
+ if (ost->enc_ctx->pix_fmt == AV_PIX_FMT_NONE)
return NULL;
- return av_strdup(av_get_pix_fmt_name(ost->st->codec->pix_fmt));
+ return av_strdup(av_get_pix_fmt_name(ost->enc_ctx->pix_fmt));
}
- if (ost->st->codec->pix_fmt != AV_PIX_FMT_NONE) {
- return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc, ost->st->codec->pix_fmt)));
+ if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
+ return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt)));
} else if (ost->enc && ost->enc->pix_fmts) {
const enum AVPixelFormat *p;
AVIOContext *s = NULL;
exit_program(1);
p = ost->enc->pix_fmts;
- if (ost->st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
- if (ost->st->codec->codec_id == AV_CODEC_ID_MJPEG) {
+ if (ost->enc_ctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
+ if (ost->enc_ctx->codec_id == AV_CODEC_ID_MJPEG) {
p = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE };
- } else if (ost->st->codec->codec_id == AV_CODEC_ID_LJPEG) {
+ } else if (ost->enc_ctx->codec_id == AV_CODEC_ID_LJPEG) {
p = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P,
AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_BGRA, AV_PIX_FMT_NONE };
}
#define DEF_CHOOSE_FORMAT(type, var, supported_list, none, get_name) \
static char *choose_ ## var ## s(OutputStream *ost) \
{ \
- if (ost->st->codec->var != none) { \
- get_name(ost->st->codec->var); \
+ if (ost->enc_ctx->var != none) { \
+ get_name(ost->enc_ctx->var); \
return av_strdup(name); \
} else if (ost->enc && ost->enc->supported_list) { \
const type *p; \
/* find the first unused stream of corresponding type */
for (i = 0; i < nb_input_streams; i++) {
ist = input_streams[i];
- if (ist->st->codec->codec_type == type && ist->discard)
+ if (ist->dec_ctx->codec_type == type && ist->discard)
break;
}
if (i == nb_input_streams) {
char *pix_fmts;
OutputStream *ost = ofilter->ost;
OutputFile *of = output_files[ost->file_index];
- AVCodecContext *codec = ost->st->codec;
+ AVCodecContext *codec = ost->enc_ctx;
AVFilterContext *last_filter = out->filter_ctx;
int pad_idx = out->pad_idx;
int ret;
{
OutputStream *ost = ofilter->ost;
OutputFile *of = output_files[ost->file_index];
- AVCodecContext *codec = ost->st->codec;
+ AVCodecContext *codec = ost->enc_ctx;
AVFilterContext *last_filter = out->filter_ctx;
int pad_idx = out->pad_idx;
char *sample_fmts, *sample_rates, *channel_layouts;
/* Compute the size of the canvas for the subtitles stream.
If the subtitles codec has set a size, use it. Otherwise use the
maximum dimensions of the video streams in the same file. */
- w = ist->st->codec->width;
- h = ist->st->codec->height;
+ w = ist->dec_ctx->width;
+ h = ist->dec_ctx->height;
if (!(w && h)) {
for (i = 0; i < avf->nb_streams; i++) {
if (avf->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
}
av_log(avf, AV_LOG_INFO, "sub2video: using %dx%d canvas\n", w, h);
}
- ist->sub2video.w = ist->st->codec->width = ist->resample_width = w;
- ist->sub2video.h = ist->st->codec->height = ist->resample_height = h;
+ ist->sub2video.w = ist->dec_ctx->width = ist->resample_width = w;
+ ist->sub2video.h = ist->dec_ctx->height = ist->resample_height = h;
/* rectangles are AV_PIX_FMT_PAL8, but we have no guarantee that the
palettes for all rectangles are identical or compatible */
- ist->resample_pix_fmt = ist->st->codec->pix_fmt = AV_PIX_FMT_RGB32;
+ ist->resample_pix_fmt = ist->dec_ctx->pix_fmt = AV_PIX_FMT_RGB32;
ist->sub2video.frame = av_frame_alloc();
if (!ist->sub2video.frame)
char name[255];
int ret, pad_idx = 0;
- if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
av_log(NULL, AV_LOG_ERROR, "Cannot connect video filter to audio input\n");
return AVERROR(EINVAL);
}
if (!fr.num)
fr = av_guess_frame_rate(input_files[ist->file_index]->ctx, ist->st, NULL);
- if (ist->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
ret = sub2video_prepare(ist);
if (ret < 0)
return ret;
sar = ist->st->sample_aspect_ratio.num ?
ist->st->sample_aspect_ratio :
- ist->st->codec->sample_aspect_ratio;
+ ist->dec_ctx->sample_aspect_ratio;
if(!sar.den)
sar = (AVRational){0,1};
av_bprint_init(&args, 0, 1);
ist->resample_height,
ist->hwaccel_retrieve_data ? ist->hwaccel_retrieved_pix_fmt : ist->resample_pix_fmt,
tb.num, tb.den, sar.num, sar.den,
- SWS_BILINEAR + ((ist->st->codec->flags&CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0));
+ SWS_BILINEAR + ((ist->dec_ctx->flags&CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0));
if (fr.num && fr.den)
av_bprintf(&args, ":frame_rate=%d/%d", fr.num, fr.den);
snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
char name[255];
int ret, pad_idx = 0;
- if (ist->st->codec->codec_type != AVMEDIA_TYPE_AUDIO) {
+ if (ist->dec_ctx->codec_type != AVMEDIA_TYPE_AUDIO) {
av_log(NULL, AV_LOG_ERROR, "Cannot connect audio filter to non audio input\n");
return AVERROR(EINVAL);
}
av_bprint_init(&args, 0, AV_BPRINT_SIZE_AUTOMATIC);
av_bprintf(&args, "time_base=%d/%d:sample_rate=%d:sample_fmt=%s",
- 1, ist->st->codec->sample_rate,
- ist->st->codec->sample_rate,
- av_get_sample_fmt_name(ist->st->codec->sample_fmt));
- if (ist->st->codec->channel_layout)
+ 1, ist->dec_ctx->sample_rate,
+ ist->dec_ctx->sample_rate,
+ av_get_sample_fmt_name(ist->dec_ctx->sample_fmt));
+ if (ist->dec_ctx->channel_layout)
av_bprintf(&args, ":channel_layout=0x%"PRIx64,
- ist->st->codec->channel_layout);
+ ist->dec_ctx->channel_layout);
else
- av_bprintf(&args, ":channels=%d", ist->st->codec->channels);
+ av_bprintf(&args, ":channels=%d", ist->dec_ctx->channels);
snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
ist->file_index, ist->st->index);