|
|
@@ -255,6 +255,21 @@ int ff_set_dimensions(AVCodecContext *s, int width, int height) |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
int ff_set_sar(AVCodecContext *avctx, AVRational sar) |
|
|
|
{ |
|
|
|
int ret = av_image_check_sar(avctx->width, avctx->height, sar); |
|
|
|
|
|
|
|
if (ret < 0) { |
|
|
|
av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n", |
|
|
|
sar.num, sar.den); |
|
|
|
avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; |
|
|
|
return ret; |
|
|
|
} else { |
|
|
|
avctx->sample_aspect_ratio = sar; |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int ff_side_data_update_matrix_encoding(AVFrame *frame, |
|
|
|
enum AVMatrixEncoding matrix_encoding) |
|
|
|
{ |
|
|
@@ -803,6 +818,15 @@ int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame) |
|
|
|
frame->format = avctx->pix_fmt; |
|
|
|
if (!frame->sample_aspect_ratio.num) |
|
|
|
frame->sample_aspect_ratio = avctx->sample_aspect_ratio; |
|
|
|
|
|
|
|
if (av_image_check_sar(frame->width, frame->height, |
|
|
|
frame->sample_aspect_ratio) < 0) { |
|
|
|
av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n", |
|
|
|
frame->sample_aspect_ratio.num, |
|
|
|
frame->sample_aspect_ratio.den); |
|
|
|
frame->sample_aspect_ratio = (AVRational){ 0, 1 }; |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
case AVMEDIA_TYPE_AUDIO: |
|
|
|
if (!frame->sample_rate) |
|
|
@@ -1365,6 +1389,16 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code |
|
|
|
ff_set_dimensions(avctx, 0, 0); |
|
|
|
} |
|
|
|
|
|
|
|
if (avctx->width > 0 && avctx->height > 0) { |
|
|
|
if (av_image_check_sar(avctx->width, avctx->height, |
|
|
|
avctx->sample_aspect_ratio) < 0) { |
|
|
|
av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n", |
|
|
|
avctx->sample_aspect_ratio.num, |
|
|
|
avctx->sample_aspect_ratio.den); |
|
|
|
avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* if the decoder init function was already called previously, |
|
|
|
* free the already allocated subtitle_header before overwriting it */ |
|
|
|
if (av_codec_is_decoder(codec)) |
|
|
|