1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

lavc, lavfi: fix counting number of planes in AVBufferRef wrappers

Number of planes is not always equal to the number of components even
for formats marked with PIX_FMT_PLANAR -- e.g. NV12 has three components
in two planes.
This commit is contained in:
Anton Khirnov 2013-03-16 22:36:56 +01:00
parent 2c328a9079
commit c977039e58
2 changed files with 4 additions and 4 deletions

View File

@ -660,11 +660,11 @@ do { \
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) { if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
if (!desc) { planes = av_pix_fmt_count_planes(frame->format);
if (!desc || planes <= 0) {
ret = AVERROR(EINVAL); ret = AVERROR(EINVAL);
goto fail; goto fail;
} }
planes = (desc->flags & PIX_FMT_PLANAR) ? desc->nb_components : 1;
for (i = 0; i < planes; i++) { for (i = 0; i < planes; i++) {
int v_shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0; int v_shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;

View File

@ -186,11 +186,11 @@ do { \
if (ctx->outputs[0]->type == AVMEDIA_TYPE_VIDEO) { if (ctx->outputs[0]->type == AVMEDIA_TYPE_VIDEO) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
if (!desc) { planes = av_pix_fmt_count_planes(frame->format);
if (!desc || planes <= 0) {
ret = AVERROR(EINVAL); ret = AVERROR(EINVAL);
goto fail; goto fail;
} }
planes = (desc->flags & PIX_FMT_PLANAR) ? desc->nb_components : 1;
for (i = 0; i < planes; i++) { for (i = 0; i < planes; i++) {
int v_shift = (i == 1 || i == 2) ? desc->log2_chroma_w : 0; int v_shift = (i == 1 || i == 2) ? desc->log2_chroma_w : 0;