static char *choose_pix_fmts(OutputStream *ost) { 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->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->enc_ctx->pix_fmt == AV_PIX_FMT_NONE) return NULL; return av_strdup(av_get_pix_fmt_name(ost->enc_ctx->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; uint8_t *ret; int len; if (avio_open_dyn_buf(&s) < 0) exit_program(1); p = ost->enc->pix_fmts; 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->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 }; }
static char *choose_pix_fmts(OutputStream *ost) { 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->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->enc_ctx->pix_fmt == AV_PIX_FMT_NONE) { return NULL; } return av_strdup(av_get_pix_fmt_name(ost->enc_ctx->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; uint8_t *ret; int len; if(avio_open_dyn_buf(&s) < 0) { exit_program(1); } p = ost->enc->pix_fmts; if(ost->enc_ctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) { p = get_compliance_unofficial_pix_fmts(ost->enc_ctx->codec_id, p); } for(; *p != AV_PIX_FMT_NONE; p++) { const char *name = av_get_pix_fmt_name(*p); avio_printf(s, "%s|", name); } len = avio_close_dyn_buf(s, &ret); ret[len - 1] = 0; return ret; } else { return NULL; } }
void FilterGraph::setAutoConvert(unsigned flags) { if (m_raw) { avfilter_graph_set_auto_convert(m_raw, flags); } }