diff --git a/examples/hvd_decoding_example.c b/examples/hvd_decoding_example.c index cb086ed..bd5f8c1 100644 --- a/examples/hvd_decoding_example.c +++ b/examples/hvd_decoding_example.c @@ -101,7 +101,7 @@ int process_user_input(int argc, char **argv, struct hvd_config *config) { if(argc < 3) { - fprintf(stderr, "Usage: %s [device]\n\n", argv[0]); + fprintf(stderr, "Usage: %s [device] [width] [height] [profile]\n\n", argv[0]); fprintf(stderr, "examples: \n"); fprintf(stderr, "%s vaapi h264 \n", argv[0]); fprintf(stderr, "%s vdpau h264 \n", argv[0]); @@ -110,6 +110,7 @@ int process_user_input(int argc, char **argv, struct hvd_config *config) fprintf(stderr, "%s dxva2 h264 \n", argv[0]); fprintf(stderr, "%s d3d11va h264 \n", argv[0]); fprintf(stderr, "%s videotoolbox h264 \n", argv[0]); + fprintf(stderr, "%s vaapi hevc /dev/dri/renderD128 848 480 1 \n", argv[0]); return 1; } @@ -117,6 +118,10 @@ int process_user_input(int argc, char **argv, struct hvd_config *config) config->codec = argv[2]; config->device = argv[3]; //NULL or device, both are ok + if(argc >= 5) config->width = atoi(argv[4]); + if(argc >= 6) config->height = atoi(argv[5]); + if(argc >= 7) config->profile = atoi(argv[6]); + return 0; } diff --git a/hvd.c b/hvd.c index e737e18..578978c 100644 --- a/hvd.c +++ b/hvd.c @@ -81,6 +81,12 @@ struct hvd *hvd_init(const struct hvd_config *config) return hvd_close_and_return_null(h); } + h->decoder_ctx->width = config->width; + h->decoder_ctx->height = config->height; + + if(config->profile) + h->decoder_ctx->profile = config->profile; + //Set user data carried by AVContext, we need this to determine pixel format //from within FFmpeg using our supplied function for decoder_ctx->get_format. //This is MUCH easier in FFmpeg 4.0 with avcodec_get_hw_config but we want diff --git a/hvd.h b/hvd.h index a3d8efd..4e18e8b 100644 --- a/hvd.h +++ b/hvd.h @@ -80,6 +80,25 @@ struct hvd; * For pixel format explanation see: * FFmpeg pixel formats * + * You typically don't have to specify width, height and profile (leave as 0) but some codecs need this information. + * + * For width and height the decoder may overwrite your values while parsing the data. + * It is not safe to assume that width/height of decoded frame matches what you supplied. + * + * For possible profiles see: + * FFmpeg profiles + * + * For H.264 profile can typically be: + * - FF_PROFILE_H264_CONSTRAINED_BASELINE + * - FF_PROFILE_H264_MAIN + * - FF_PROFILE_H264_HIGH + * - ... + * + * For HEVC profile can typically be: + * - FF_PROFILE_HEVC_MAIN + * - FF_PROFILE_HEVC_MAIN_10 (10 bit channel precision) + * - ... + * * @see hvd_init */ struct hvd_config @@ -88,6 +107,9 @@ struct hvd_config const char *codec; //!< codec name, e.g. "h264", "vp8" const char *device; //!< NULL / "" or device, e.g. "/dev/dri/renderD128" const char *pixel_format; //!< NULL / "" for default or format, e.g. "rgb0", "bgr0", "nv12", "yuv420p" + int width; //!< 0 to not specify, needed by some codecs + int height; //!< 0 to not specify, needed by some codecs + int profile; //!< 0 to leave as FF_PROFILE_UNKNOWN or profile e.g. FF_PROFILE_HEVC_MAIN, ... }; /**