v4l2-h264.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Helper functions for H264 codecs.
  4. *
  5. * Copyright (c) 2019 Collabora, Ltd.
  6. *
  7. * Author: Boris Brezillon <[email protected]>
  8. */
  9. #ifndef _MEDIA_V4L2_H264_H
  10. #define _MEDIA_V4L2_H264_H
  11. #include <media/v4l2-ctrls.h>
  12. /**
  13. * struct v4l2_h264_reflist_builder - Reference list builder object
  14. *
  15. * @refs.top_field_order_cnt: top field order count
  16. * @refs.bottom_field_order_cnt: bottom field order count
  17. * @refs.frame_num: reference frame number
  18. * @refs.longterm: set to true for a long term reference
  19. * @refs: array of references
  20. * @cur_pic_order_count: picture order count of the frame being decoded
  21. * @cur_pic_fields: fields present in the frame being decoded
  22. * @unordered_reflist: unordered list of references. Will be used to generate
  23. * ordered P/B0/B1 lists
  24. * @num_valid: number of valid references in the refs array
  25. *
  26. * This object stores the context of the P/B0/B1 reference list builder.
  27. * This procedure is described in section '8.2.4 Decoding process for reference
  28. * picture lists construction' of the H264 spec.
  29. */
  30. struct v4l2_h264_reflist_builder {
  31. struct {
  32. s32 top_field_order_cnt;
  33. s32 bottom_field_order_cnt;
  34. int frame_num;
  35. u16 longterm : 1;
  36. } refs[V4L2_H264_NUM_DPB_ENTRIES];
  37. s32 cur_pic_order_count;
  38. u8 cur_pic_fields;
  39. struct v4l2_h264_reference unordered_reflist[V4L2_H264_REF_LIST_LEN];
  40. u8 num_valid;
  41. };
  42. void
  43. v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b,
  44. const struct v4l2_ctrl_h264_decode_params *dec_params,
  45. const struct v4l2_ctrl_h264_sps *sps,
  46. const struct v4l2_h264_dpb_entry dpb[V4L2_H264_NUM_DPB_ENTRIES]);
  47. /**
  48. * v4l2_h264_build_b_ref_lists() - Build the B0/B1 reference lists
  49. *
  50. * @builder: reference list builder context
  51. * @b0_reflist: 32 sized array used to store the B0 reference list. Each entry
  52. * is a v4l2_h264_reference structure
  53. * @b1_reflist: 32 sized array used to store the B1 reference list. Each entry
  54. * is a v4l2_h264_reference structure
  55. *
  56. * This functions builds the B0/B1 reference lists. This procedure is described
  57. * in section '8.2.4 Decoding process for reference picture lists construction'
  58. * of the H264 spec. This function can be used by H264 decoder drivers that
  59. * need to pass B0/B1 reference lists to the hardware.
  60. */
  61. void
  62. v4l2_h264_build_b_ref_lists(const struct v4l2_h264_reflist_builder *builder,
  63. struct v4l2_h264_reference *b0_reflist,
  64. struct v4l2_h264_reference *b1_reflist);
  65. /**
  66. * v4l2_h264_build_p_ref_list() - Build the P reference list
  67. *
  68. * @builder: reference list builder context
  69. * @reflist: 32 sized array used to store the P reference list. Each entry
  70. * is a v4l2_h264_reference structure
  71. *
  72. * This functions builds the P reference lists. This procedure is describe in
  73. * section '8.2.4 Decoding process for reference picture lists construction'
  74. * of the H264 spec. This function can be used by H264 decoder drivers that
  75. * need to pass a P reference list to the hardware.
  76. */
  77. void
  78. v4l2_h264_build_p_ref_list(const struct v4l2_h264_reflist_builder *builder,
  79. struct v4l2_h264_reference *reflist);
  80. #endif /* _MEDIA_V4L2_H264_H */