49     for (
i = 0; 
i < 
ctx->nb_filter_buffers; 
i++) {
 
   50         if (
ctx->filter_buffers[
i] != VA_INVALID_ID) {
 
   51             vaDestroyBuffer(
ctx->hwctx->display, 
ctx->filter_buffers[
i]);
 
   52             ctx->filter_buffers[
i] = VA_INVALID_ID;
 
   55     ctx->nb_filter_buffers = 0;
 
   57     if (
ctx->va_context != VA_INVALID_ID) {
 
   58         vaDestroyContext(
ctx->hwctx->display, 
ctx->va_context);
 
   59         ctx->va_context = VA_INVALID_ID;
 
   62     if (
ctx->va_config != VA_INVALID_ID) {
 
   63         vaDestroyConfig(
ctx->hwctx->display, 
ctx->va_config);
 
   64         ctx->va_config = VA_INVALID_ID;
 
   77     if (
ctx->pipeline_uninit)
 
   78         ctx->pipeline_uninit(avctx);
 
   82                "required to associate the processing device.\n");
 
   87     if (!
ctx->input_frames_ref) {
 
  111     if (
ctx->pipeline_uninit)
 
  112         ctx->pipeline_uninit(avctx);
 
  114     if (!
ctx->output_width)
 
  116     if (!
ctx->output_height)
 
  119     outlink->
w = 
ctx->output_width;
 
  120     outlink->
h = 
ctx->output_height;
 
  122     if (
ctx->passthrough) {
 
  132     if (!
ctx->device_ref) {
 
  140     vas = vaCreateConfig(
ctx->hwctx->display, VAProfileNone,
 
  141                          VAEntrypointVideoProc, 
NULL, 0, &
ctx->va_config);
 
  142     if (vas != VA_STATUS_SUCCESS) {
 
  144                "config: %d (%s).\n", vas, vaErrorStr(vas));
 
  164         ctx->output_format = 
ctx->input_frames->sw_format;
 
  183                "size %dx%d (constraints: width %d-%d height %d-%d).\n",
 
  184                ctx->output_width, 
ctx->output_height,
 
  203     output_frames->
width     = 
ctx->output_width;
 
  204     output_frames->
height    = 
ctx->output_height;
 
  218                "context for output: %d\n", err);
 
  222     va_frames = output_frames->
hwctx;
 
  227     vas = vaCreateContext(
ctx->hwctx->display, 
ctx->va_config,
 
  228                           ctx->output_width, 
ctx->output_height,
 
  232     if (vas != VA_STATUS_SUCCESS) {
 
  234                "context: %d (%s).\n", vas, vaErrorStr(vas));
 
  238     if (
ctx->build_filter_params) {
 
  239         err = 
ctx->build_filter_params(avctx);
 
  270     { VAProcColorStandardBT601,       5,  6,  5 },
 
  271     { VAProcColorStandardBT601,       6,  6,  6 },
 
  272     { VAProcColorStandardBT709,       1,  1,  1 },
 
  273     { VAProcColorStandardBT470M,      4,  4,  4 },
 
  274     { VAProcColorStandardBT470BG,     5,  5,  5 },
 
  275     { VAProcColorStandardSMPTE170M,   6,  6,  6 },
 
  276     { VAProcColorStandardSMPTE240M,   7,  7,  7 },
 
  277     { VAProcColorStandardGenericFilm, 8,  1,  1 },
 
  278 #if VA_CHECK_VERSION(1, 1, 0) 
  279     { VAProcColorStandardSRGB,        1, 13,  0 },
 
  280     { VAProcColorStandardXVYCC601,    1, 11,  5 },
 
  281     { VAProcColorStandardXVYCC709,    1, 11,  1 },
 
  282     { VAProcColorStandardBT2020,      9, 14,  9 },
 
  287                                            VAProcColorStandardType *vacs,
 
  291     int i, j, score, best_score, worst_score;
 
  292     VAProcColorStandardType best_standard;
 
  294 #if VA_CHECK_VERSION(1, 3, 0) 
  299     for (
i = 0; 
i < nb_vacs; 
i++) {
 
  300         if (vacs[
i] == VAProcColorStandardExplicit) {
 
  312     best_standard = VAProcColorStandardNone;
 
  319     if (worst_score == 0) {
 
  326     for (
i = 0; 
i < nb_vacs; 
i++) {
 
  342             if (score < worst_score &&
 
  343                 (best_score == -1 || score < best_score)) {
 
  354 #if VA_CHECK_VERSION(1, 1, 0) 
  355     static const struct {
 
  361                                     VA_CHROMA_SITING_HORIZONTAL_LEFT },
 
  363                                     VA_CHROMA_SITING_HORIZONTAL_CENTER },
 
  365                                     VA_CHROMA_SITING_HORIZONTAL_LEFT },
 
  367                                     VA_CHROMA_SITING_HORIZONTAL_CENTER },
 
  369                                     VA_CHROMA_SITING_HORIZONTAL_LEFT },
 
  371                                     VA_CHROMA_SITING_HORIZONTAL_CENTER },
 
  389 #if VA_CHECK_VERSION(1, 1, 0) 
  408                                              VAProcColorStandardType *vacs,
 
  416            "to VA standard %d chroma siting %#x range %#x.\n",
 
  431                frame->hw_frames_ctx);
 
  439                                        VAProcPipelineParameterBuffer *params,
 
  445     VAProcPipelineCaps caps;
 
  448     vas = vaQueryVideoProcPipelineCaps(
ctx->hwctx->display, 
ctx->va_context,
 
  449                                        ctx->filter_buffers, 
ctx->nb_filter_buffers,
 
  451     if (vas != VA_STATUS_SUCCESS) {
 
  453                "colour standard support: %d (%s).\n", vas, vaErrorStr(vas));
 
  467                                      caps.input_color_standards,
 
  468                                      caps.num_input_color_standards);
 
  476         .chroma_sample_location = 
output_frame->chroma_location,
 
  479                                      caps.output_color_standards,
 
  480                                      caps.num_output_color_standards);
 
  484 #if VA_CHECK_VERSION(1, 3, 0) 
  498         if (output_standard) {
 
  509 #if VA_CHECK_VERSION(1, 1, 0) 
  510     params->input_color_properties = (VAProcColorProperties) {
 
  513 #if VA_CHECK_VERSION(1, 3, 0) 
  515         .transfer_characteristics = input_props.
color_trc,
 
  516         .matrix_coefficients      = input_props.
colorspace,
 
  519     params->output_color_properties = (VAProcColorProperties) {
 
  522 #if VA_CHECK_VERSION(1, 3, 0) 
  524         .transfer_characteristics = output_props.
color_trc,
 
  525         .matrix_coefficients      = output_props.
colorspace,
 
  534                              VAProcPipelineParameterBuffer *params,
 
  541     ctx->input_region = (VARectangle) {
 
  544         .width  = input_frame->
width -
 
  554     *params = (VAProcPipelineParameterBuffer) {
 
  556         .surface_region          = &
ctx->input_region,
 
  557         .output_region           = 
NULL,
 
  560         .filter_flags            = VA_FRAME_PICTURE,
 
  564 #if VA_CHECK_VERSION(1, 1, 0) 
  565         .rotation_state = VA_ROTATION_NONE,
 
  566         .mirror_state   = VA_MIRROR_NONE,
 
  594     vas = vaCreateBuffer(
ctx->hwctx->display, 
ctx->va_context,
 
  596     if (vas != VA_STATUS_SUCCESS) {
 
  598                "buffer (type %d): %d (%s).\n",
 
  599                type, vas, vaErrorStr(vas));
 
  611                                                    VAProcPipelineParameterBuffer *params,
 
  612                                                    VABufferID *params_id)
 
  617     vas = vaCreateBuffer(
ctx->hwctx->display, 
ctx->va_context,
 
  618                          VAProcPipelineParameterBufferType,
 
  619                          sizeof(*params), 1, params, params_id);
 
  620     if (vas != VA_STATUS_SUCCESS) {
 
  622                "%d (%s).\n", vas, vaErrorStr(vas));
 
  623         *params_id = VA_INVALID_ID;
 
  629     vas = vaRenderPicture(
ctx->hwctx->display, 
ctx->va_context, params_id, 1);
 
  630     if (vas != VA_STATUS_SUCCESS) {
 
  632                "%d (%s).\n", vas, vaErrorStr(vas));
 
  640                                  VAProcPipelineParameterBuffer *params_list,
 
  645     VABufferID *params_ids;
 
  653     for (
int i = 0; 
i < cout; 
i++)
 
  654         params_ids[
i] = VA_INVALID_ID;
 
  656     vas = vaBeginPicture(
ctx->hwctx->display,
 
  658     if (vas != VA_STATUS_SUCCESS) {
 
  660                "%d (%s).\n", vas, vaErrorStr(vas));
 
  665     for (
int i = 0; 
i < cout; 
i++) {
 
  668             goto fail_after_begin;
 
  671     vas = vaEndPicture(
ctx->hwctx->display, 
ctx->va_context);
 
  672     if (vas != VA_STATUS_SUCCESS) {
 
  674                "%d (%s).\n", vas, vaErrorStr(vas));
 
  676         goto fail_after_render;
 
  679     if (CONFIG_VAAPI_1 || 
ctx->hwctx->driver_quirks &
 
  681         for (
int i = 0; 
i < cout && params_ids[
i] != VA_INVALID_ID; 
i++) {
 
  682             vas = vaDestroyBuffer(
ctx->hwctx->display, params_ids[
i]);
 
  683             if (vas != VA_STATUS_SUCCESS) {
 
  685                        "%d (%s).\n", vas, vaErrorStr(vas));
 
  699     vaRenderPicture(
ctx->hwctx->display, 
ctx->va_context, ¶ms_ids[0], 1);
 
  701     vaEndPicture(
ctx->hwctx->display, 
ctx->va_context);
 
  708                                 VAProcPipelineParameterBuffer *params,
 
  719     ctx->va_config  = VA_INVALID_ID;
 
  720     ctx->va_context = VA_INVALID_ID;
 
  723     for (
i = 0; 
i < VAProcFilterCount; 
i++)
 
  724         ctx->filter_buffers[
i] = VA_INVALID_ID;
 
  725     ctx->nb_filter_buffers = 0;
 
  731     if (
ctx->valid_ids && 
ctx->pipeline_uninit)
 
  732         ctx->pipeline_uninit(avctx);