~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/vulkan/runtime/vk_video.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include "vk_log.h"
27
27
#include "vk_alloc.h"
28
28
#include "vk_device.h"
 
29
#include "util/vl_rbsp.h"
29
30
 
30
31
VkResult
31
32
vk_video_session_init(struct vk_device *device,
366
367
{
367
368
   return find_h265_dec_std_pps(params, id);
368
369
}
 
370
 
 
371
int
 
372
vk_video_h265_poc_by_slot(const struct VkVideoDecodeInfoKHR *frame_info, int slot)
 
373
{
 
374
   for (unsigned i = 0; i < frame_info->referenceSlotCount; i++) {
 
375
      const VkVideoDecodeH265DpbSlotInfoKHR *dpb_slot_info =
 
376
         vk_find_struct_const(frame_info->pReferenceSlots[i].pNext, VIDEO_DECODE_H265_DPB_SLOT_INFO_KHR);
 
377
      if (frame_info->pReferenceSlots[i].slotIndex == slot)
 
378
         return dpb_slot_info->pStdReferenceInfo->PicOrderCntVal;
 
379
   }
 
380
 
 
381
   assert(0);
 
382
 
 
383
   return 0;
 
384
}
 
385
 
 
386
void
 
387
vk_fill_video_h265_reference_info(const VkVideoDecodeInfoKHR *frame_info,
 
388
                                  const struct VkVideoDecodeH265PictureInfoKHR *pic,
 
389
                                  const struct vk_video_h265_slice_params *slice_params,
 
390
                                  struct vk_video_h265_reference ref_slots[][8])
 
391
{
 
392
   uint8_t list_cnt = slice_params->slice_type == STD_VIDEO_H265_SLICE_TYPE_B ? 2 : 1;
 
393
   uint8_t list_idx;
 
394
   int i, j;
 
395
 
 
396
   for (list_idx = 0; list_idx < list_cnt; list_idx++) {
 
397
      /* The order is
 
398
       *  L0: Short term current before set - Short term current after set - long term current
 
399
       *  L1: Short term current after set - short term current before set - long term current
 
400
       */
 
401
      const uint8_t *rps[3] = {
 
402
         list_idx ? pic->pStdPictureInfo->RefPicSetStCurrAfter : pic->pStdPictureInfo->RefPicSetStCurrBefore,
 
403
         list_idx ? pic->pStdPictureInfo->RefPicSetStCurrBefore : pic->pStdPictureInfo->RefPicSetStCurrAfter,
 
404
         pic->pStdPictureInfo->RefPicSetLtCurr
 
405
      };
 
406
 
 
407
      uint8_t ref_idx = 0;
 
408
      for (i = 0; i < 3; i++) {
 
409
         const uint8_t *cur_rps = rps[i];
 
410
 
 
411
         for (j = 0; (cur_rps[j] != 0xff) && ((j + ref_idx) < 8); j++) {
 
412
            ref_slots[list_idx][j + ref_idx].slot_index = cur_rps[j];
 
413
            ref_slots[list_idx][j + ref_idx].pic_order_cnt = vk_video_h265_poc_by_slot(frame_info, cur_rps[j]);
 
414
         }
 
415
         ref_idx += j;
 
416
      }
 
417
 
 
418
      /* TODO: should handle cases where rpl_modification_flag is true. */
 
419
      assert(!slice_params->rpl_modification_flag[0] && !slice_params->rpl_modification_flag[1]);
 
420
   }
 
421
}
 
422
 
 
423
static void
 
424
h265_pred_weight_table(struct vk_video_h265_slice_params *params,
 
425
                       struct vl_rbsp *rbsp,
 
426
                       const StdVideoH265SequenceParameterSet *sps,
 
427
                       StdVideoH265SliceType slice_type)
 
428
{
 
429
   unsigned chroma_array_type = sps->flags.separate_colour_plane_flag ? 0 : sps->chroma_format_idc;
 
430
   unsigned i, j;
 
431
 
 
432
   params->luma_log2_weight_denom = vl_rbsp_ue(rbsp);
 
433
 
 
434
   assert(params->luma_log2_weight_denom >= 0 && params->luma_log2_weight_denom < 8);
 
435
 
 
436
   if (chroma_array_type != 0) {
 
437
      params->chroma_log2_weight_denom = params->luma_log2_weight_denom + vl_rbsp_se(rbsp);
 
438
      assert(params->chroma_log2_weight_denom >= 0 && params->chroma_log2_weight_denom < 8);
 
439
   }
 
440
 
 
441
   for (i = 0; i < params->num_ref_idx_l0_active; ++i) {
 
442
      params->luma_weight_l0_flag[i] = vl_rbsp_u(rbsp, 1);
 
443
      if (!params->luma_weight_l0_flag[i]) {
 
444
         params->luma_weight_l0[i] = 1 << params->luma_log2_weight_denom;
 
445
         params->luma_offset_l0[i] = 0;
 
446
      }
 
447
   }
 
448
 
 
449
   for (i = 0; i < params->num_ref_idx_l0_active; ++i) {
 
450
      if (chroma_array_type == 0) {
 
451
         params->chroma_weight_l0_flag[i] = 0;
 
452
      } else {
 
453
         params->chroma_weight_l0_flag[i] = vl_rbsp_u(rbsp, 1);
 
454
      }
 
455
   }
 
456
 
 
457
   for (i = 0; i < params->num_ref_idx_l0_active; ++i) {
 
458
      if (params->luma_weight_l0_flag[i]) {
 
459
         params->delta_luma_weight_l0[i] = vl_rbsp_se(rbsp);
 
460
         params->luma_weight_l0[i] = (1 << params->luma_log2_weight_denom) + params->delta_luma_weight_l0[i];
 
461
         params->luma_offset_l0[i] = vl_rbsp_se(rbsp);
 
462
      }
 
463
 
 
464
      if (params->chroma_weight_l0_flag[i]) {
 
465
         for (j = 0; j < 2; j++) {
 
466
            params->delta_chroma_weight_l0[i][j] = vl_rbsp_se(rbsp);
 
467
            params->delta_chroma_offset_l0[i][j] = vl_rbsp_se(rbsp);
 
468
 
 
469
            params->chroma_weight_l0[i][j] =
 
470
               (1 << params->chroma_log2_weight_denom) + params->delta_chroma_weight_l0[i][j];
 
471
            params->chroma_offset_l0[i][j] = CLAMP(params->delta_chroma_offset_l0[i][j] -
 
472
               ((128 * params->chroma_weight_l0[i][j]) >> params->chroma_log2_weight_denom) + 128, -128, 127);
 
473
         }
 
474
      } else {
 
475
         for (j = 0; j < 2; j++) {
 
476
            params->chroma_weight_l0[i][j] = 1 << params->chroma_log2_weight_denom;
 
477
            params->chroma_offset_l0[i][j] = 0;
 
478
         }
 
479
      }
 
480
   }
 
481
 
 
482
   if (slice_type == STD_VIDEO_H265_SLICE_TYPE_B) {
 
483
      for (i = 0; i < params->num_ref_idx_l1_active; ++i) {
 
484
         params->luma_weight_l1_flag[i] = vl_rbsp_u(rbsp, 1);
 
485
         if (!params->luma_weight_l1_flag[i]) {
 
486
            params->luma_weight_l1[i] = 1 << params->luma_log2_weight_denom;
 
487
            params->luma_offset_l1[i] = 0;
 
488
         }
 
489
      }
 
490
 
 
491
      for (i = 0; i < params->num_ref_idx_l1_active; ++i) {
 
492
         if (chroma_array_type == 0) {
 
493
            params->chroma_weight_l1_flag[i] = 0;
 
494
         } else {
 
495
            params->chroma_weight_l1_flag[i] = vl_rbsp_u(rbsp, 1);
 
496
         }
 
497
      }
 
498
 
 
499
      for (i = 0; i < params->num_ref_idx_l1_active; ++i) {
 
500
         if (params->luma_weight_l1_flag[i]) {
 
501
            params->delta_luma_weight_l1[i] = vl_rbsp_se(rbsp);
 
502
            params->luma_weight_l1[i] =
 
503
               (1 << params->luma_log2_weight_denom) + params->delta_luma_weight_l1[i];
 
504
            params->luma_offset_l1[i] = vl_rbsp_se(rbsp);
 
505
         }
 
506
 
 
507
         if (params->chroma_weight_l1_flag[i]) {
 
508
            for (j = 0; j < 2; j++) {
 
509
               params->delta_chroma_weight_l1[i][j] = vl_rbsp_se(rbsp);
 
510
               params->delta_chroma_offset_l1[i][j] = vl_rbsp_se(rbsp);
 
511
 
 
512
               params->chroma_weight_l1[i][j] =
 
513
                  (1 << params->chroma_log2_weight_denom) + params->delta_chroma_weight_l1[i][j];
 
514
               params->chroma_offset_l1[i][j] = CLAMP(params->delta_chroma_offset_l1[i][j] -
 
515
                  ((128 * params->chroma_weight_l1[i][j]) >> params->chroma_log2_weight_denom) + 128, -128, 127);
 
516
            }
 
517
         } else {
 
518
            for (j = 0; j < 2; j++) {
 
519
               params->chroma_weight_l1[i][j] = 1 << params->chroma_log2_weight_denom;
 
520
               params->chroma_offset_l1[i][j] = 0;
 
521
            }
 
522
         }
 
523
      }
 
524
   }
 
525
}
 
526
 
 
527
void
 
528
vk_video_parse_h265_slice_header(const struct VkVideoDecodeInfoKHR *frame_info,
 
529
                                 const VkVideoDecodeH265PictureInfoKHR *pic_info,
 
530
                                 const StdVideoH265SequenceParameterSet *sps,
 
531
                                 const StdVideoH265PictureParameterSet *pps,
 
532
                                 void *slice_data,
 
533
                                 uint32_t slice_size,
 
534
                                 struct vk_video_h265_slice_params *params)
 
535
{
 
536
   struct vl_vlc vlc;
 
537
   const void *slice_headers[1] = { slice_data };
 
538
   vl_vlc_init(&vlc, 1, slice_headers, &slice_size);
 
539
 
 
540
   assert(vl_vlc_peekbits(&vlc, 24) == 0x000001);
 
541
 
 
542
   vl_vlc_eatbits(&vlc, 24);
 
543
 
 
544
   /* forbidden_zero_bit */
 
545
   vl_vlc_eatbits(&vlc, 1);
 
546
 
 
547
   if (vl_vlc_valid_bits(&vlc) < 15)
 
548
      vl_vlc_fillbits(&vlc);
 
549
 
 
550
   vl_vlc_get_uimsbf(&vlc, 6); /* nal_unit_type */
 
551
   vl_vlc_get_uimsbf(&vlc, 6); /* nuh_layer_id */
 
552
   vl_vlc_get_uimsbf(&vlc, 3); /* nuh_temporal_id_plus1 */
 
553
 
 
554
   struct vl_rbsp rbsp;
 
555
   vl_rbsp_init(&rbsp, &vlc, 128);
 
556
 
 
557
   memset(params, 0, sizeof(*params));
 
558
 
 
559
   params->slice_size = slice_size;
 
560
   params->first_slice_segment_in_pic_flag = vl_rbsp_u(&rbsp, 1);
 
561
 
 
562
   /* no_output_of_prior_pics_flag */
 
563
   if (pic_info->pStdPictureInfo->flags.IrapPicFlag)
 
564
      vl_rbsp_u(&rbsp, 1);
 
565
 
 
566
   /* pps id */
 
567
   vl_rbsp_ue(&rbsp);
 
568
 
 
569
   if (!params->first_slice_segment_in_pic_flag) {
 
570
      int size, num;
 
571
      int bits_slice_segment_address = 0;
 
572
 
 
573
      if (pps->flags.dependent_slice_segments_enabled_flag)
 
574
         params->dependent_slice_segment = vl_rbsp_u(&rbsp, 1);
 
575
 
 
576
      size = 1 << (sps->log2_min_luma_coding_block_size_minus3 + 3 +
 
577
                   sps->log2_diff_max_min_luma_coding_block_size);
 
578
 
 
579
      num = ((sps->pic_width_in_luma_samples + size - 1) / size) *
 
580
            ((sps->pic_height_in_luma_samples + size - 1) / size);
 
581
 
 
582
      while (num > (1 << bits_slice_segment_address))
 
583
         bits_slice_segment_address++;
 
584
 
 
585
      /* slice_segment_address */
 
586
      params->slice_segment_address = vl_rbsp_u(&rbsp, bits_slice_segment_address);
 
587
   }
 
588
 
 
589
   if (params->dependent_slice_segment)
 
590
      return;
 
591
 
 
592
   for (unsigned i = 0; i < pps->num_extra_slice_header_bits; ++i)
 
593
      /* slice_reserved_flag */
 
594
      vl_rbsp_u(&rbsp, 1);
 
595
 
 
596
   /* slice_type */
 
597
   params->slice_type = vl_rbsp_ue(&rbsp);
 
598
 
 
599
   if (pps->flags.output_flag_present_flag)
 
600
      /* pic output flag */
 
601
      vl_rbsp_u(&rbsp, 1);
 
602
 
 
603
   if (sps->flags.separate_colour_plane_flag)
 
604
      /* colour_plane_id */
 
605
      vl_rbsp_u(&rbsp, 2);
 
606
 
 
607
   if (!pic_info->pStdPictureInfo->flags.IdrPicFlag) {
 
608
      /* slice_pic_order_cnt_lsb */
 
609
      params->pic_order_cnt_lsb =
 
610
         vl_rbsp_u(&rbsp, sps->log2_max_pic_order_cnt_lsb_minus4 + 4);
 
611
 
 
612
      /* short_term_ref_pic_set_sps_flag */
 
613
      if (!vl_rbsp_u(&rbsp, 1)) {
 
614
         uint8_t rps_predict = 0;
 
615
 
 
616
         if (sps->num_short_term_ref_pic_sets)
 
617
            rps_predict = vl_rbsp_u(&rbsp, 1);
 
618
 
 
619
         if (rps_predict) {
 
620
            /* delta_idx */
 
621
            vl_rbsp_ue(&rbsp);
 
622
            /* delta_rps_sign */
 
623
            vl_rbsp_u(&rbsp, 1);
 
624
            /* abs_delta_rps */
 
625
            vl_rbsp_ue(&rbsp);
 
626
 
 
627
            for (int i = 0 ; i <= pic_info->pStdPictureInfo->NumDeltaPocsOfRefRpsIdx; i++) {
 
628
               uint8_t used = vl_rbsp_u(&rbsp, 1);
 
629
               if (!used)
 
630
                  vl_rbsp_u(&rbsp, 1);
 
631
            }
 
632
         } else {
 
633
            /* num_negative_pics */
 
634
            unsigned num_neg_pics = vl_rbsp_ue(&rbsp);
 
635
            /* num_positive_pics */
 
636
            unsigned num_pos_pics = vl_rbsp_ue(&rbsp);
 
637
 
 
638
            for(unsigned i = 0 ; i < num_neg_pics; ++i) {
 
639
               /* delta_poc_s0_minus1 */
 
640
               vl_rbsp_ue(&rbsp);
 
641
               /* used_by_curr_pic_s0_flag */
 
642
               vl_rbsp_u(&rbsp, 1);
 
643
            }
 
644
 
 
645
            for(unsigned i = 0; i < num_pos_pics; ++i) {
 
646
               /* delta_poc_s1_minus1 */
 
647
               vl_rbsp_ue(&rbsp);
 
648
               /* used_by_curr_pic_s0_flag */
 
649
               vl_rbsp_u(&rbsp, 1);
 
650
            }
 
651
         }
 
652
 
 
653
      } else {
 
654
         unsigned num_st_rps = sps->num_short_term_ref_pic_sets;
 
655
 
 
656
         int numbits = util_logbase2_ceil(num_st_rps);
 
657
         if (numbits > 0)
 
658
            /* short_term_ref_pic_set_idx */
 
659
            vl_rbsp_u(&rbsp, numbits);
 
660
      }
 
661
 
 
662
      if (sps->flags.long_term_ref_pics_present_flag) {
 
663
         unsigned num_lt_sps = 0;
 
664
 
 
665
         if (sps->num_long_term_ref_pics_sps > 0)
 
666
            num_lt_sps = vl_rbsp_ue(&rbsp);
 
667
 
 
668
         unsigned num_lt_pics = vl_rbsp_ue(&rbsp);
 
669
         unsigned num_refs = num_lt_pics + num_lt_sps;
 
670
 
 
671
         for (unsigned i = 0; i < num_refs; i++) {
 
672
            if (i < num_lt_sps) {
 
673
               if (sps->num_long_term_ref_pics_sps > 1)
 
674
                  /* lt_idx_sps */
 
675
                  vl_rbsp_u(&rbsp,
 
676
                        util_logbase2_ceil(sps->num_long_term_ref_pics_sps));
 
677
            } else {
 
678
               /* poc_lsb_lt */
 
679
               vl_rbsp_u(&rbsp, sps->log2_max_pic_order_cnt_lsb_minus4 + 4);
 
680
               /* used_by_curr_pic_lt_flag */
 
681
               vl_rbsp_u(&rbsp, 1);
 
682
            }
 
683
 
 
684
            /* poc_msb_present */
 
685
            if (vl_rbsp_u(&rbsp, 1)) {
 
686
               /* delta_poc_msb_cycle_lt */
 
687
               vl_rbsp_ue(&rbsp);
 
688
            }
 
689
         }
 
690
      }
 
691
 
 
692
      if (sps->flags.sps_temporal_mvp_enabled_flag)
 
693
         params->temporal_mvp_enable = vl_rbsp_u(&rbsp, 1);
 
694
   }
 
695
 
 
696
   if (sps->flags.sample_adaptive_offset_enabled_flag) {
 
697
      params->sao_luma_flag = vl_rbsp_u(&rbsp, 1);
 
698
      if (sps->chroma_format_idc)
 
699
         params->sao_chroma_flag = vl_rbsp_u(&rbsp, 1);
 
700
   }
 
701
 
 
702
   params->max_num_merge_cand = 5;
 
703
 
 
704
   if (params->slice_type != STD_VIDEO_H265_SLICE_TYPE_I) {
 
705
 
 
706
      params->num_ref_idx_l0_active = pps->num_ref_idx_l0_default_active_minus1 + 1;
 
707
 
 
708
      if (params->slice_type == STD_VIDEO_H265_SLICE_TYPE_B)
 
709
         params->num_ref_idx_l1_active = pps->num_ref_idx_l1_default_active_minus1 + 1;
 
710
      else
 
711
         params->num_ref_idx_l1_active = 0;
 
712
 
 
713
      /* num_ref_idx_active_override_flag */
 
714
      if (vl_rbsp_u(&rbsp, 1)) {
 
715
         params->num_ref_idx_l0_active = vl_rbsp_ue(&rbsp) + 1;
 
716
         if (params->slice_type == STD_VIDEO_H265_SLICE_TYPE_B)
 
717
            params->num_ref_idx_l1_active = vl_rbsp_ue(&rbsp) + 1;
 
718
      }
 
719
 
 
720
      if (pps->flags.lists_modification_present_flag) {
 
721
         params->rpl_modification_flag[0] = vl_rbsp_u(&rbsp, 1);
 
722
         if (params->rpl_modification_flag[0]) {
 
723
            for (int i = 0; i < params->num_ref_idx_l0_active; i++) {
 
724
               /* list_entry_l0 */
 
725
               vl_rbsp_u(&rbsp,
 
726
                     util_logbase2_ceil(params->num_ref_idx_l0_active + params->num_ref_idx_l1_active));
 
727
            }
 
728
         }
 
729
 
 
730
         if (params->slice_type == STD_VIDEO_H265_SLICE_TYPE_B) {
 
731
            params->rpl_modification_flag[1] = vl_rbsp_u(&rbsp, 1);
 
732
            if (params->rpl_modification_flag[1]) {
 
733
               for (int i = 0; i < params->num_ref_idx_l1_active; i++) {
 
734
                  /* list_entry_l1 */
 
735
                  vl_rbsp_u(&rbsp,
 
736
                        util_logbase2_ceil(params->num_ref_idx_l0_active + params->num_ref_idx_l1_active));
 
737
               }
 
738
            }
 
739
         }
 
740
      }
 
741
 
 
742
      if (params->slice_type == STD_VIDEO_H265_SLICE_TYPE_B)
 
743
         params->mvd_l1_zero_flag = vl_rbsp_u(&rbsp, 1);
 
744
 
 
745
      if (pps->flags.cabac_init_present_flag)
 
746
         /* cabac_init_flag */
 
747
         params->cabac_init_idc = vl_rbsp_u(&rbsp, 1);
 
748
 
 
749
      if (params->temporal_mvp_enable) {
 
750
         if (params->slice_type == STD_VIDEO_H265_SLICE_TYPE_B)
 
751
            params->collocated_list = !vl_rbsp_u(&rbsp, 1);
 
752
 
 
753
         if (params->collocated_list == 0) {
 
754
            if (params->num_ref_idx_l0_active > 1)
 
755
               params->collocated_ref_idx = vl_rbsp_ue(&rbsp);
 
756
         }  else if (params->collocated_list == 1) {
 
757
            if (params->num_ref_idx_l1_active > 1)
 
758
               params->collocated_ref_idx = vl_rbsp_ue(&rbsp);
 
759
         }
 
760
      }
 
761
 
 
762
      if ((pps->flags.weighted_pred_flag && params->slice_type == STD_VIDEO_H265_SLICE_TYPE_P) ||
 
763
            (pps->flags.weighted_bipred_flag && params->slice_type == STD_VIDEO_H265_SLICE_TYPE_B)) {
 
764
         h265_pred_weight_table(params, &rbsp, sps, params->slice_type);
 
765
      }
 
766
 
 
767
      params->max_num_merge_cand -= vl_rbsp_ue(&rbsp);
 
768
   }
 
769
 
 
770
   params->slice_qp_delta = vl_rbsp_se(&rbsp);
 
771
 
 
772
   if (pps->flags.pps_slice_chroma_qp_offsets_present_flag) {
 
773
      params->slice_cb_qp_offset = vl_rbsp_se(&rbsp);
 
774
      params->slice_cr_qp_offset = vl_rbsp_se(&rbsp);
 
775
   }
 
776
 
 
777
   if (pps->flags.chroma_qp_offset_list_enabled_flag)
 
778
      /* cu_chroma_qp_offset_enabled_flag */
 
779
      vl_rbsp_u(&rbsp, 1);
 
780
 
 
781
   if (pps->flags.deblocking_filter_control_present_flag) {
 
782
      if (pps->flags.deblocking_filter_override_enabled_flag) {
 
783
         /* deblocking_filter_override_flag */
 
784
         if (vl_rbsp_u(&rbsp, 1)) {
 
785
            params->disable_deblocking_filter_idc = vl_rbsp_u(&rbsp, 1);
 
786
 
 
787
            if (!params->disable_deblocking_filter_idc) {
 
788
               params->beta_offset_div2 = vl_rbsp_se(&rbsp);
 
789
               params->tc_offset_div2 = vl_rbsp_se(&rbsp);
 
790
            }
 
791
         } else {
 
792
            params->disable_deblocking_filter_idc =
 
793
               pps->flags.pps_deblocking_filter_disabled_flag;
 
794
         }
 
795
      }
 
796
   }
 
797
 
 
798
   if (pps->flags.pps_loop_filter_across_slices_enabled_flag &&
 
799
         (params->sao_luma_flag || params->sao_chroma_flag ||
 
800
          !params->disable_deblocking_filter_idc))
 
801
      params->loop_filter_across_slices_enable = vl_rbsp_u(&rbsp, 1);
 
802
 
 
803
   if (pps->flags.tiles_enabled_flag || pps->flags.entropy_coding_sync_enabled_flag) {
 
804
      unsigned num_entry_points_offsets = vl_rbsp_ue(&rbsp);
 
805
 
 
806
      if (num_entry_points_offsets > 0) {
 
807
         unsigned offset_len = vl_rbsp_ue(&rbsp) + 1;
 
808
         for (unsigned i = 0; i < num_entry_points_offsets; i++) {
 
809
            /* entry_point_offset_minus1 */
 
810
            vl_rbsp_u(&rbsp, offset_len);
 
811
         }
 
812
      }
 
813
   }
 
814
 
 
815
   if (pps->flags.pps_extension_present_flag) {
 
816
      unsigned length = vl_rbsp_ue(&rbsp);
 
817
      for (unsigned i = 0; i < length; i++)
 
818
         /* slice_reserved_undetermined_flag */
 
819
         vl_rbsp_u(&rbsp, 1);
 
820
   }
 
821
 
 
822
   unsigned header_bits =
 
823
      (slice_size * 8 - 24 /* start code */) - vl_vlc_bits_left(&rbsp.nal) - rbsp.removed;
 
824
   params->slice_data_bytes_offset = (header_bits + 8) / 8;
 
825
}
 
826
 
 
827
void
 
828
vk_video_get_profile_alignments(const VkVideoProfileListInfoKHR *profile_list,
 
829
                                uint32_t *width_align_out, uint32_t *height_align_out)
 
830
{
 
831
   uint32_t width_align = 1, height_align = 1;
 
832
   for (unsigned i = 0; i < profile_list->profileCount; i++) {
 
833
      if (profile_list->pProfiles[i].videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) {
 
834
         width_align = MAX2(width_align, VK_VIDEO_H264_MACROBLOCK_WIDTH);
 
835
         height_align = MAX2(height_align, VK_VIDEO_H264_MACROBLOCK_HEIGHT);
 
836
      }
 
837
      if (profile_list->pProfiles[i].videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR) {
 
838
         width_align = MAX2(width_align, VK_VIDEO_H265_CTU_MAX_WIDTH);
 
839
         height_align = MAX2(height_align, VK_VIDEO_H265_CTU_MAX_HEIGHT);
 
840
      }
 
841
   }
 
842
   *width_align_out = width_align;
 
843
   *height_align_out = height_align;
 
844
}