mirror of
https://github.com/mpv-player/mpv
synced 2025-01-18 21:31:13 +00:00
video: do not use deprecated libavutil pixdesc fields
These were normalized and are saner now. We want to use the new fields, and also get rid of the deprecation warnings, so use them. There's no release yet which uses these, so some ifdeffery is unfortunately needed.
This commit is contained in:
parent
a8eae12af5
commit
9e04e31906
@ -798,6 +798,12 @@ api_statement_check \
|
||||
libavutil/avutil.h \
|
||||
'const char *x = av_version_info()'
|
||||
|
||||
api_statement_check \
|
||||
"libavutil new pixdesc fields" \
|
||||
HAVE_AV_NEW_PIXDESC \
|
||||
libavutil/pixdesc.h \
|
||||
'AVComponentDescriptor d; int x = d.depth'
|
||||
|
||||
check_pkg_config "libavfilter" $_libavfilter LIBAVFILTER 'libavfilter >= 5.0.0'
|
||||
|
||||
check_pkg_config "libavdevice" $_libavdevice LIBAVDEVICE 'libavdevice >= 55.0.0'
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include <libavutil/pixfmt.h>
|
||||
#include <libavutil/pixdesc.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "video/img_format.h"
|
||||
#include "video/mp_image.h"
|
||||
#include "video/fmt-conversion.h"
|
||||
@ -142,7 +144,6 @@ struct mp_imgfmt_desc mp_imgfmt_get_desc(int mpfmt)
|
||||
.avformat = fmt,
|
||||
.chroma_xs = pd->log2_chroma_w,
|
||||
.chroma_ys = pd->log2_chroma_h,
|
||||
.component_bits = pd->comp[0].depth_minus1 + 1,
|
||||
};
|
||||
|
||||
int planedepth[4] = {0};
|
||||
@ -150,12 +151,21 @@ struct mp_imgfmt_desc mp_imgfmt_get_desc(int mpfmt)
|
||||
bool need_endian = false; // single component is spread over >1 bytes
|
||||
for (int c = 0; c < pd->nb_components; c++) {
|
||||
AVComponentDescriptor d = pd->comp[c];
|
||||
#if HAVE_AV_NEW_PIXDESC
|
||||
int depth = d.depth;
|
||||
int step = d.step;
|
||||
#else
|
||||
int depth = d.depth_minus1 + 1;
|
||||
int step = d.step_minus1 + 1;
|
||||
#endif
|
||||
// multiple components per plane -> Y is definitive, ignore chroma
|
||||
if (!desc.bpp[d.plane])
|
||||
desc.bpp[d.plane] = (d.step_minus1 + 1) * el_size;
|
||||
planedepth[d.plane] += d.depth_minus1 + 1;
|
||||
need_endian |= (d.depth_minus1 + 1 + d.shift) > 8;
|
||||
if (d.depth_minus1 + 1 != desc.component_bits)
|
||||
desc.bpp[d.plane] = step * el_size;
|
||||
planedepth[d.plane] += depth;
|
||||
need_endian |= (depth + d.shift) > 8;
|
||||
if (c == 0)
|
||||
desc.component_bits = depth;
|
||||
if (depth != desc.component_bits)
|
||||
desc.component_bits = 0;
|
||||
}
|
||||
|
||||
|
6
wscript
6
wscript
@ -447,6 +447,12 @@ FFmpeg/Libav libraries. You need at least {0}. Aborting.".format(libav_versions_
|
||||
'func': check_statement('libavutil/avutil.h',
|
||||
'const char *x = av_version_info()',
|
||||
use='libav'),
|
||||
}, {
|
||||
'name': 'av-new-pixdesc',
|
||||
'desc': 'libavutil new pixdesc fields',
|
||||
'func': check_statement('libavutil/pixdesc.h',
|
||||
'AVComponentDescriptor d; int x = d.depth',
|
||||
use='libav'),
|
||||
}
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user