Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr rext support #41

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion libavcodec/Makefile
Expand Up @@ -879,7 +879,7 @@ OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL) += dxva2_hevc.o
OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o
OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o
OBJS-$(CONFIG_HEVC_QSV_HWACCEL) += qsvdec_h2645.o
OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o
OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o h265_profile_level.o
OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o
OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL) += nvdec_mjpeg.o
OBJS-$(CONFIG_MJPEG_VAAPI_HWACCEL) += vaapi_mjpeg.o
Expand Down
44 changes: 40 additions & 4 deletions libavcodec/hevc_ps.c
Expand Up @@ -267,7 +267,7 @@ static int decode_profile_tier_level(GetBitContext *gb, AVCodecContext *avctx,
{
int i;

if (get_bits_left(gb) < 2+1+5 + 32 + 4 + 16 + 16 + 12)
if (get_bits_left(gb) < 2+1+5 + 32 + 4 + 43 + 1)
return -1;

ptl->profile_space = get_bits(gb, 2);
Expand Down Expand Up @@ -295,9 +295,45 @@ static int decode_profile_tier_level(GetBitContext *gb, AVCodecContext *avctx,
ptl->non_packed_constraint_flag = get_bits1(gb);
ptl->frame_only_constraint_flag = get_bits1(gb);

skip_bits(gb, 16); // XXX_reserved_zero_44bits[0..15]
skip_bits(gb, 16); // XXX_reserved_zero_44bits[16..31]
skip_bits(gb, 12); // XXX_reserved_zero_44bits[32..43]
#define check_profile_idc(idc) \
ptl->profile_idc == idc || ptl->profile_compatibility_flag[idc]

if (check_profile_idc(4) || check_profile_idc(5) || check_profile_idc(6) ||
check_profile_idc(7) || check_profile_idc(8) || check_profile_idc(9) ||
check_profile_idc(10)) {

ptl->max_12bit_constraint_flag = get_bits1(gb);
ptl->max_10bit_constraint_flag = get_bits1(gb);
ptl->max_8bit_constraint_flag = get_bits1(gb);
ptl->max_422chroma_constraint_flag = get_bits1(gb);
ptl->max_420chroma_constraint_flag = get_bits1(gb);
ptl->max_monochrome_constraint_flag = get_bits1(gb);
ptl->intra_constraint_flag = get_bits1(gb);
ptl->one_picture_only_constraint_flag = get_bits1(gb);
ptl->lower_bit_rate_constraint_flag = get_bits1(gb);

if (check_profile_idc(5) || check_profile_idc(9) || check_profile_idc(10)) {
ptl->max_14bit_constraint_flag = get_bits1(gb);
skip_bits_long(gb, 33); // XXX_reserved_zero_33bits[0..32]
} else {
skip_bits_long(gb, 34); // XXX_reserved_zero_34bits[0..33]
}
} else if (check_profile_idc(2)) {
skip_bits(gb, 7);
ptl->one_picture_only_constraint_flag = get_bits1(gb);
skip_bits_long(gb, 35); // XXX_reserved_zero_35bits[0..34]
} else {
skip_bits_long(gb, 43); // XXX_reserved_zero_43bits[0..42]
}

if ((ptl->profile_idc >=1 && ptl->profile_idc <= 5) || ptl->profile_idc == 9 ||
ptl->profile_compatibility_flag[1] || ptl->profile_compatibility_flag[2] ||
ptl->profile_compatibility_flag[3] || ptl->profile_compatibility_flag[4] ||
ptl->profile_compatibility_flag[5] || ptl->profile_compatibility_flag[9])
ptl->inbld_flag = get_bits1(gb);
else
skip_bits1(gb);
#undef check_profile_idc

return 0;
}
Expand Down
13 changes: 12 additions & 1 deletion libavcodec/hevc_ps.h
Expand Up @@ -177,11 +177,22 @@ typedef struct PTLCommon {
uint8_t tier_flag;
uint8_t profile_idc;
uint8_t profile_compatibility_flag[32];
uint8_t level_idc;
uint8_t progressive_source_flag;
uint8_t interlaced_source_flag;
uint8_t non_packed_constraint_flag;
uint8_t frame_only_constraint_flag;
uint8_t max_12bit_constraint_flag;
uint8_t max_10bit_constraint_flag;
uint8_t max_8bit_constraint_flag;
uint8_t max_422chroma_constraint_flag;
uint8_t max_420chroma_constraint_flag;
uint8_t max_monochrome_constraint_flag;
uint8_t intra_constraint_flag;
uint8_t one_picture_only_constraint_flag;
uint8_t lower_bit_rate_constraint_flag;
uint8_t max_14bit_constraint_flag;
uint8_t inbld_flag;
uint8_t level_idc;
} PTLCommon;

typedef struct PTL {
Expand Down
11 changes: 10 additions & 1 deletion libavcodec/hevcdec.c
Expand Up @@ -419,16 +419,25 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps)
*fmt++ = AV_PIX_FMT_CUDA;
#endif
break;
case AV_PIX_FMT_YUV422P:
case AV_PIX_FMT_YUV422P10LE:
#if CONFIG_HEVC_VAAPI_HWACCEL
*fmt++ = AV_PIX_FMT_VAAPI;
#endif
break;
case AV_PIX_FMT_YUV444P:
case AV_PIX_FMT_YUV444P10:
#if CONFIG_HEVC_VDPAU_HWACCEL
*fmt++ = AV_PIX_FMT_VDPAU;
#endif
#if CONFIG_HEVC_NVDEC_HWACCEL
*fmt++ = AV_PIX_FMT_CUDA;
#endif
#if CONFIG_HEVC_VAAPI_HWACCEL
*fmt++ = AV_PIX_FMT_VAAPI;
#endif
break;
case AV_PIX_FMT_YUV420P12:
case AV_PIX_FMT_YUV444P10:
case AV_PIX_FMT_YUV444P12:
#if CONFIG_HEVC_NVDEC_HWACCEL
*fmt++ = AV_PIX_FMT_CUDA;
Expand Down
83 changes: 53 additions & 30 deletions libavcodec/vaapi_decode.c
Expand Up @@ -24,7 +24,7 @@
#include "decode.h"
#include "internal.h"
#include "vaapi_decode.h"

#include "vaapi_hevc.h"

int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx,
VAAPIDecodePicture *pic,
Expand Down Expand Up @@ -255,11 +255,23 @@ static const struct {
MAP(422H, YUV422P),
#ifdef VA_FOURCC_YV16
MAP(YV16, YUV422P),
#endif
#ifdef VA_FOURCC_YUY2
MAP(YUY2, YUYV422),
#endif
#ifdef VA_FOURCC_Y210
MAP(Y210, Y210LE),
#endif
// 4:4:0
MAP(422V, YUV440P),
// 4:4:4
MAP(444P, YUV444P),
#ifdef VA_FOURCC_AYUV
MAP(AYUV, AYUV),
#endif
#ifdef VA_FOURCC_Y410
MAP(Y410, Y410LE),
#endif
// 4:2:0 10-bit
#ifdef VA_FOURCC_P010
MAP(P010, P010),
Expand Down Expand Up @@ -364,39 +376,44 @@ static const struct {
enum AVCodecID codec_id;
int codec_profile;
VAProfile va_profile;
VAProfile (*profile_parser)(AVCodecContext *avctx);
} vaapi_profile_map[] = {
#define MAP(c, p, v) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, VAProfile ## v }
MAP(MPEG2VIDEO, MPEG2_SIMPLE, MPEG2Simple ),
MAP(MPEG2VIDEO, MPEG2_MAIN, MPEG2Main ),
MAP(H263, UNKNOWN, H263Baseline),
MAP(MPEG4, MPEG4_SIMPLE, MPEG4Simple ),
#define MAP(c, p, v, f) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, VAProfile ## v, f}
MAP(MPEG2VIDEO, MPEG2_SIMPLE, MPEG2Simple , NULL ),
MAP(MPEG2VIDEO, MPEG2_MAIN, MPEG2Main , NULL ),
MAP(H263, UNKNOWN, H263Baseline, NULL ),
MAP(MPEG4, MPEG4_SIMPLE, MPEG4Simple , NULL ),
MAP(MPEG4, MPEG4_ADVANCED_SIMPLE,
MPEG4AdvancedSimple),
MAP(MPEG4, MPEG4_MAIN, MPEG4Main ),
MPEG4AdvancedSimple, NULL ),
MAP(MPEG4, MPEG4_MAIN, MPEG4Main , NULL ),
MAP(H264, H264_CONSTRAINED_BASELINE,
H264ConstrainedBaseline),
MAP(H264, H264_MAIN, H264Main ),
MAP(H264, H264_HIGH, H264High ),
H264ConstrainedBaseline, NULL ),
MAP(H264, H264_MAIN, H264Main , NULL ),
MAP(H264, H264_HIGH, H264High , NULL ),
#if VA_CHECK_VERSION(0, 37, 0)
MAP(HEVC, HEVC_MAIN, HEVCMain ),
MAP(HEVC, HEVC_MAIN_10, HEVCMain10 ),
MAP(HEVC, HEVC_MAIN, HEVCMain , NULL ),
MAP(HEVC, HEVC_MAIN_10, HEVCMain10 , NULL ),
#endif
#if VA_CHECK_VERSION(1, 2, 0)
MAP(HEVC, HEVC_REXT, None,
ff_vaapi_parse_rext_profile),
#endif
MAP(MJPEG, MJPEG_HUFFMAN_BASELINE_DCT,
JPEGBaseline),
MAP(WMV3, VC1_SIMPLE, VC1Simple ),
MAP(WMV3, VC1_MAIN, VC1Main ),
MAP(WMV3, VC1_COMPLEX, VC1Advanced ),
MAP(WMV3, VC1_ADVANCED, VC1Advanced ),
MAP(VC1, VC1_SIMPLE, VC1Simple ),
MAP(VC1, VC1_MAIN, VC1Main ),
MAP(VC1, VC1_COMPLEX, VC1Advanced ),
MAP(VC1, VC1_ADVANCED, VC1Advanced ),
MAP(VP8, UNKNOWN, VP8Version0_3 ),
JPEGBaseline, NULL ),
MAP(WMV3, VC1_SIMPLE, VC1Simple , NULL ),
MAP(WMV3, VC1_MAIN, VC1Main , NULL ),
MAP(WMV3, VC1_COMPLEX, VC1Advanced , NULL ),
MAP(WMV3, VC1_ADVANCED, VC1Advanced , NULL ),
MAP(VC1, VC1_SIMPLE, VC1Simple , NULL ),
MAP(VC1, VC1_MAIN, VC1Main , NULL ),
MAP(VC1, VC1_COMPLEX, VC1Advanced , NULL ),
MAP(VC1, VC1_ADVANCED, VC1Advanced , NULL ),
MAP(VP8, UNKNOWN, VP8Version0_3 , NULL ),
#if VA_CHECK_VERSION(0, 38, 0)
MAP(VP9, VP9_0, VP9Profile0 ),
MAP(VP9, VP9_0, VP9Profile0 , NULL ),
#endif
#if VA_CHECK_VERSION(0, 39, 0)
MAP(VP9, VP9_2, VP9Profile2 ),
MAP(VP9, VP9_2, VP9Profile2 , NULL ),
#endif
#undef MAP
};
Expand All @@ -415,8 +432,8 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
VAStatus vas;
int err, i, j;
const AVCodecDescriptor *codec_desc;
VAProfile *profile_list = NULL, matched_va_profile;
int profile_count, exact_match, matched_ff_profile;
VAProfile *profile_list = NULL, matched_va_profile, tmp_va_profile;
int profile_count, exact_match, matched_ff_profile, tmp_codec_profile;

AVHWDeviceContext *device = (AVHWDeviceContext*)device_ref->data;
AVVAAPIDeviceContext *hwctx = device->hwctx;
Expand Down Expand Up @@ -454,15 +471,21 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
if (avctx->profile == vaapi_profile_map[i].codec_profile ||
vaapi_profile_map[i].codec_profile == FF_PROFILE_UNKNOWN)
profile_match = 1;

tmp_va_profile = vaapi_profile_map[i].profile_parser ?
vaapi_profile_map[i].profile_parser(avctx) :
vaapi_profile_map[i].va_profile;
tmp_codec_profile = vaapi_profile_map[i].codec_profile;

for (j = 0; j < profile_count; j++) {
if (vaapi_profile_map[i].va_profile == profile_list[j]) {
if (tmp_va_profile == profile_list[j]) {
exact_match = profile_match;
break;
}
}
if (j < profile_count) {
matched_va_profile = vaapi_profile_map[i].va_profile;
matched_ff_profile = vaapi_profile_map[i].codec_profile;
matched_va_profile = tmp_va_profile;
matched_ff_profile = tmp_codec_profile;
if (exact_match)
break;
}
Expand Down